Skip to content

Commit

Permalink
change object-caching (fabricjs#5566)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Mar 9, 2019
1 parent 349c4f8 commit c084cf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/shapes/group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,13 @@

/**
* 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.
* Generally you do not cache objects in groups because the group outside is cached.
* Generally you do not cache objects in groups because the group is already cached.
* @return {Boolean}
*/
shouldCache: function() {
var ownCache = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isOnACache());
this.ownCaching = ownCache;
var ownCache = fabric.Object.prototype.shouldCache.call(this);
if (ownCache) {
for (var i = 0, len = this._objects.length; i < len; i++) {
if (this._objects[i].willDrawShadow()) {
Expand Down
4 changes: 1 addition & 3 deletions src/shapes/image.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@

/**
* 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.
* Generally you do not cache objects in groups because the group outside is cached.
Expand All @@ -515,8 +514,7 @@
* @return {Boolean}
*/
shouldCache: function() {
this.ownCaching = this.objectCaching && this.needsItsOwnCache();
return this.ownCaching;
return this.needsItsOwnCache();
},

_renderFill: function(ctx) {
Expand Down
12 changes: 8 additions & 4 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,16 +522,17 @@

/**
* When `true`, object is not exported in OBJECT/JSON
* since 1.6.3
* @since 1.6.3
* @type Boolean
* @default
*/
excludeFromExport: false,

/**
* When `true`, object is cached on an additional canvas.
* When `false`, object is not cached unless necessary ( clipPath )
* default to true
* since 1.7.0
* @since 1.7.0
* @type Boolean
* @default true
*/
Expand Down Expand Up @@ -1139,11 +1140,14 @@
* 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.
* Read as: cache if is needed, or if the feature is enabled but we are not already caching.
* @return {Boolean}
*/
shouldCache: function() {
this.ownCaching = this.objectCaching &&
(!this.group || this.needsItsOwnCache() || !this.group.isOnACache());
this.ownCaching = this.needsItsOwnCache() || (
this.objectCaching &&
(!this.group || !this.group.isOnACache())
);
return this.ownCaching;
},

Expand Down

0 comments on commit c084cf1

Please sign in to comment.