Skip to content

Commit

Permalink
added missing functions (#3877)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Apr 24, 2017
1 parent 17035c7 commit 4d4b8f1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/shapes/path_group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 4d4b8f1

Please sign in to comment.