Name change of some caching method (#4034)

* just name change
* fixed test
This commit is contained in:
Andrea Bogazzi 2017-06-25 12:52:59 +02:00 committed by GitHub
parent 7a88afb2d3
commit 46af53a95b
3 changed files with 16 additions and 18 deletions

View file

@ -313,7 +313,7 @@
},
/**
* Decide if the object should cache or not.
* Decide if the object should cache or not. Create its own cache level
* objectCaching is a global flag, wins over everything
* needsItsOwnCache should be used when the object drawing method requires
* a cache step. None of the fabric classes requires it.
@ -321,17 +321,17 @@
* @return {Boolean}
*/
shouldCache: function() {
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isCaching());
this.caching = parentCache;
if (parentCache) {
var ownCache = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isOnACache());
this.ownCaching = ownCache;
if (ownCache) {
for (var i = 0, len = this._objects.length; i < len; i++) {
if (this._objects[i].willDrawShadow()) {
this.caching = false;
this.ownCaching = false;
return false;
}
}
}
return parentCache;
return ownCache;
},
/**
@ -354,8 +354,8 @@
* Check if this group or its parent group are caching, recursively up
* @return {Boolean}
*/
isCaching: function() {
return this.caching || this.group && this.group.isCaching();
isOnACache: function() {
return this.ownCaching || (this.group && this.group.isOnACache());
},
/**
@ -413,11 +413,6 @@
* @private
*/
_renderObject: function(object, ctx) {
// do not render if object is not visible
if (!object.visible) {
return;
}
var originalHasRotatingPoint = object.hasRotatingPoint;
object.hasRotatingPoint = false;
object.render(ctx);

View file

@ -1083,7 +1083,7 @@
this.dirty = true;
}
if (this.group && this.stateProperties.indexOf(key) > -1) {
if (this.group && this.stateProperties.indexOf(key) > -1 && this.group.isOnACache()) {
this.group.set('dirty', true);
}
@ -1140,7 +1140,6 @@
return;
}
ctx.save();
//setup fill rule for current object
this._setupCompositeOperation(ctx);
this.drawSelectionBackground(ctx);
this.transform(ctx);
@ -1185,7 +1184,7 @@
},
/**
* Decide if the object should cache or not.
* Decide if the object should cache or not. Create its own cache level
* objectCaching is a global flag, wins over everything
* needsItsOwnCache should be used when the object drawing method requires
* a cache step. None of the fabric classes requires it.
@ -1193,8 +1192,9 @@
* @return {Boolean}
*/
shouldCache: function() {
return this.objectCaching &&
(!this.group || this.needsItsOwnCache() || !this.group.isCaching());
this.ownCaching = this.objectCaching &&
(!this.group || this.needsItsOwnCache() || !this.group.isOnACache());
return this.ownCaching;
},
/**

View file

@ -519,6 +519,9 @@
var obj = g1.item(0);
g1.dirty = false;
obj.dirty = false;
// specify that the group is caching or the test will fail under node since the
// object caching is disabled by default
g1.ownCaching = true;
equal(g1.dirty, false, 'Group has no dirty flag set');
obj.set('angle', 5);
equal(obj.dirty, false, 'Obj has dirty flag still false');