mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-05 20:34:45 +00:00
added missing functions (#3877)
This commit is contained in:
parent
17035c7480
commit
4d4b8f1088
1 changed files with 46 additions and 0 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue