mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-14 00:33:09 +00:00
parent
0bf4b2a7f7
commit
044770c6f9
5 changed files with 22 additions and 27 deletions
|
|
@ -36,7 +36,8 @@
|
|||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "node build.js modules=ALL exclude=json,gestures",
|
||||
"build:watch": "onchange 'src/**/**' 'test/**/**' 'HEADER.js' 'lib/**/**' -- npm run build",
|
||||
"build_export": "npm run build && npm run export_dist_to_site",
|
||||
"build:watch": "onchange 'src/**/**' 'test/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
|
||||
"build_with_gestures": "node build.js modules=ALL exclude=json",
|
||||
"test": "node test.js",
|
||||
"lint": "eslint --config .eslintrc.json src",
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@
|
|||
* @return {Boolean}
|
||||
*/
|
||||
shouldCache: function() {
|
||||
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache || !this.group.isCaching());
|
||||
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isCaching());
|
||||
this.caching = parentCache;
|
||||
if (parentCache) {
|
||||
for (var i = 0, len = this._objects.length; i < len; i++) {
|
||||
|
|
|
|||
|
|
@ -796,16 +796,6 @@
|
|||
*/
|
||||
dirty: true,
|
||||
|
||||
/**
|
||||
* When set to `true`, force the object to have its own cache, even if it is inside a group
|
||||
* it may be needed when your object behave in a particular way on the cache and always needs
|
||||
* its own isolated canvas to render correctly.
|
||||
* since 1.7.5
|
||||
* @type Boolean
|
||||
* @default false
|
||||
*/
|
||||
needsItsOwnCache: false,
|
||||
|
||||
/**
|
||||
* List of properties to consider when checking if state
|
||||
* of an object is changed (fabric.Object#hasStateChanged)
|
||||
|
|
@ -837,9 +827,6 @@
|
|||
if (options) {
|
||||
this.setOptions(options);
|
||||
}
|
||||
if (this.objectCaching) {
|
||||
this._createCacheCanvas();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -1154,7 +1141,7 @@
|
|||
ctx.transform.apply(ctx, this.transformMatrix);
|
||||
}
|
||||
this.clipTo && fabric.util.clipContext(this, ctx);
|
||||
if (this.shouldCache()) {
|
||||
if (this.shouldCache(noTransform)) {
|
||||
if (!this._cacheCanvas) {
|
||||
this._createCacheCanvas();
|
||||
}
|
||||
|
|
@ -1175,17 +1162,31 @@
|
|||
ctx.restore();
|
||||
},
|
||||
|
||||
/**
|
||||
* When returns `true`, force the object to have its own cache, even if it is inside a group
|
||||
* it may be needed when your object behave in a particular way on the cache and always needs
|
||||
* its own isolated canvas to render correctly.
|
||||
* This function is created to be subclassed by custom classes.
|
||||
* since 1.7.12
|
||||
* @type function
|
||||
* @return false
|
||||
*/
|
||||
needsItsOwnCache: function() {
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param {Boolean} noTransform if rendereing in pathGroup, caching is not supported at object level
|
||||
* @return {Boolean}
|
||||
*/
|
||||
shouldCache: function() {
|
||||
return this.objectCaching &&
|
||||
(!this.group || this.needsItsOwnCache || !this.group.isCaching());
|
||||
shouldCache: function(noTransform) {
|
||||
return !noTransform && this.objectCaching &&
|
||||
(!this.group || this.needsItsOwnCache() || !this.group.isCaching());
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -104,10 +104,6 @@
|
|||
}
|
||||
|
||||
this._setPositionDimensions(options);
|
||||
|
||||
if (this.objectCaching) {
|
||||
this._createCacheCanvas();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,9 +54,6 @@
|
|||
}
|
||||
this.setOptions(options);
|
||||
this.setCoords();
|
||||
if (this.objectCaching) {
|
||||
this._createCacheCanvas();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +109,7 @@
|
|||
* @return {Boolean}
|
||||
*/
|
||||
shouldCache: function() {
|
||||
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache || !this.group.isCaching());
|
||||
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++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue