mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Remove need for _needsRedraw() calls by replacing it with a boolean flag.
This commit is contained in:
parent
fd3f698fe9
commit
4e6f52c20c
5 changed files with 5 additions and 10 deletions
|
@ -202,7 +202,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
this._clearBoundsCache();
|
||||
}
|
||||
if (flags & /*#=*/ ChangeFlag.APPEARANCE) {
|
||||
this._project._needsRedraw();
|
||||
this._project._needsRedraw = true;
|
||||
}
|
||||
// If this item is a symbol's definition, notify it of the change too
|
||||
if (this._parentSymbol)
|
||||
|
|
|
@ -78,7 +78,7 @@ var Layer = Group.extend(/** @lends Layer# */{
|
|||
Base.splice(this._project.layers, null, this._index, 1);
|
||||
// Tell project we need a redraw. This is similar to _changed()
|
||||
// mechanism.
|
||||
this._project._needsRedraw();
|
||||
this._project._needsRedraw = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -72,11 +72,6 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
return Base.serialize(this.layers, options, false, dictionary);
|
||||
},
|
||||
|
||||
_needsRedraw: function() {
|
||||
if (this.view)
|
||||
this.view._redrawNeeded = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Activates this project, so all newly created items will be placed
|
||||
* in it.
|
||||
|
|
|
@ -44,7 +44,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
* @function
|
||||
*/
|
||||
draw: function(checkRedraw) {
|
||||
if (checkRedraw && !this._redrawNeeded)
|
||||
if (checkRedraw && !this._project._needsRedraw)
|
||||
return false;
|
||||
// Initial tests conclude that clearing the canvas using clearRect
|
||||
// is always faster than setting canvas.width = canvas.width
|
||||
|
@ -53,7 +53,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
size = this._viewSize;
|
||||
ctx.clearRect(0, 0, size._width + 1, size._height + 1);
|
||||
this._project.draw(ctx, this._matrix);
|
||||
this._redrawNeeded = false;
|
||||
this._project._needsRedraw = false;
|
||||
return true;
|
||||
}
|
||||
}, new function() { // Item based mouse handling:
|
||||
|
|
|
@ -235,7 +235,7 @@ var View = Base.extend(Callback, /** @lends View# */{
|
|||
},
|
||||
|
||||
_redraw: function() {
|
||||
this._redrawNeeded = true;
|
||||
this._project._needsRedraw = true;
|
||||
if (this._handlingFrame)
|
||||
return;
|
||||
if (this._animate) {
|
||||
|
|
Loading…
Reference in a new issue