Remove need for _needsRedraw() calls by replacing it with a boolean flag.

This commit is contained in:
Jürg Lehni 2013-05-27 23:40:23 -07:00
parent fd3f698fe9
commit 4e6f52c20c
5 changed files with 5 additions and 10 deletions

View file

@ -202,7 +202,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
this._clearBoundsCache(); this._clearBoundsCache();
} }
if (flags & /*#=*/ ChangeFlag.APPEARANCE) { 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 item is a symbol's definition, notify it of the change too
if (this._parentSymbol) if (this._parentSymbol)

View file

@ -78,7 +78,7 @@ var Layer = Group.extend(/** @lends Layer# */{
Base.splice(this._project.layers, null, this._index, 1); Base.splice(this._project.layers, null, this._index, 1);
// Tell project we need a redraw. This is similar to _changed() // Tell project we need a redraw. This is similar to _changed()
// mechanism. // mechanism.
this._project._needsRedraw(); this._project._needsRedraw = true;
return true; return true;
} }
return false; return false;

View file

@ -72,11 +72,6 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
return Base.serialize(this.layers, options, false, dictionary); 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 * Activates this project, so all newly created items will be placed
* in it. * in it.

View file

@ -44,7 +44,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
* @function * @function
*/ */
draw: function(checkRedraw) { draw: function(checkRedraw) {
if (checkRedraw && !this._redrawNeeded) if (checkRedraw && !this._project._needsRedraw)
return false; return false;
// Initial tests conclude that clearing the canvas using clearRect // Initial tests conclude that clearing the canvas using clearRect
// is always faster than setting canvas.width = canvas.width // is always faster than setting canvas.width = canvas.width
@ -53,7 +53,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
size = this._viewSize; size = this._viewSize;
ctx.clearRect(0, 0, size._width + 1, size._height + 1); ctx.clearRect(0, 0, size._width + 1, size._height + 1);
this._project.draw(ctx, this._matrix); this._project.draw(ctx, this._matrix);
this._redrawNeeded = false; this._project._needsRedraw = false;
return true; return true;
} }
}, new function() { // Item based mouse handling: }, new function() { // Item based mouse handling:

View file

@ -235,7 +235,7 @@ var View = Base.extend(Callback, /** @lends View# */{
}, },
_redraw: function() { _redraw: function() {
this._redrawNeeded = true; this._project._needsRedraw = true;
if (this._handlingFrame) if (this._handlingFrame)
return; return;
if (this._animate) { if (this._animate) {