added missing functions (#3877)

This commit is contained in:
Andrea Bogazzi 2017-04-24 09:48:56 +02:00 committed by GitHub
parent 17035c7480
commit 4d4b8f1088

View file

@ -103,6 +103,52 @@
ctx.restore();
},
/**
* Decide if the object should cache or not.
* 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.
* Generally you do not cache objects in groups because the group outside is cached.
* @return {Boolean}
*/
shouldCache: function() {
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache || !this.group.isCaching());
this.caching = parentCache;
if (parentCache) {
for (var i = 0, len = this.paths.length; i < len; i++) {
if (this.paths[i].willDrawShadow()) {
this.caching = false;
return false;
}
}
}
return parentCache;
},
/**
* Check if this object or a child object will cast a shadow
* @return {Boolean}
*/
willDrawShadow: function() {
if (this.shadow) {
return true;
}
for (var i = 0, len = this.paths.length; i < len; i++) {
if (this.paths[i].willDrawShadow()) {
return true;
}
}
return false;
},
/**
* Check if this group or its parent group are caching, recursively up
* @return {Boolean}
*/
isCaching: function() {
return this.caching || this.group && this.group.isCaching();
},
/**
* Check if cache is dirty
*/