Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: change objectCaching meaning #5566

Merged
merged 1 commit into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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