mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Remove ctx.currentPath caching again, since it has the current affine transformation factored in and is thus useless to us.
This commit is contained in:
parent
8d7fc43de2
commit
1049214126
2 changed files with 11 additions and 33 deletions
|
@ -57,13 +57,6 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
||||||
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
_changed: function _changed(flags) {
|
|
||||||
_changed.base.call(this, flags);
|
|
||||||
// Delete cached native Path
|
|
||||||
if (flags & (/*#=*/ ChangeFlag.HIERARCHY | /*#=*/ ChangeFlag.GEOMETRY))
|
|
||||||
delete this._currentPath;
|
|
||||||
},
|
|
||||||
|
|
||||||
insertChildren: function insertChildren(index, items, _preserve) {
|
insertChildren: function insertChildren(index, items, _preserve) {
|
||||||
// Pass on 'path' for _type, to make sure that only paths are added as
|
// Pass on 'path' for _type, to make sure that only paths are added as
|
||||||
// children.
|
// children.
|
||||||
|
@ -226,15 +219,10 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
||||||
if (children.length === 0)
|
if (children.length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this._currentPath) {
|
|
||||||
ctx.currentPath = this._currentPath;
|
|
||||||
} else {
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
param = param.extend({ compound: true });
|
param = param.extend({ compound: true });
|
||||||
for (var i = 0, l = children.length; i < l; i++)
|
for (var i = 0, l = children.length; i < l; i++)
|
||||||
children[i].draw(ctx, param);
|
children[i].draw(ctx, param);
|
||||||
this._currentPath = ctx.currentPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!param.clip) {
|
if (!param.clip) {
|
||||||
this._setStyles(ctx);
|
this._setStyles(ctx);
|
||||||
|
|
|
@ -115,8 +115,6 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
_changed: function _changed(flags) {
|
_changed: function _changed(flags) {
|
||||||
_changed.base.call(this, flags);
|
_changed.base.call(this, flags);
|
||||||
if (flags & /*#=*/ ChangeFlag.GEOMETRY) {
|
if (flags & /*#=*/ ChangeFlag.GEOMETRY) {
|
||||||
// Delete cached native Path
|
|
||||||
delete (this._compound ? this._parent : this)._currentPath;
|
|
||||||
delete this._length;
|
delete this._length;
|
||||||
// Clockwise state becomes undefined as soon as geometry changes.
|
// Clockwise state becomes undefined as soon as geometry changes.
|
||||||
delete this._clockwise;
|
delete this._clockwise;
|
||||||
|
@ -1998,8 +1996,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
return {
|
return {
|
||||||
_draw: function(ctx, param) {
|
_draw: function(ctx, param) {
|
||||||
var clip = param.clip,
|
var clip = param.clip,
|
||||||
// Also mark this Path as _compound so _changed() knows about it
|
compound = param.compound;
|
||||||
compound = this._compound = param.compound;
|
|
||||||
if (!compound)
|
if (!compound)
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
||||||
|
@ -2017,19 +2014,12 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
return dashArray[((i % dashLength) + dashLength) % dashLength];
|
return dashArray[((i % dashLength) + dashLength) % dashLength];
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompoundPath collects its own _currentPath
|
|
||||||
if (!compound && this._currentPath) {
|
|
||||||
ctx.currentPath = this._currentPath;
|
|
||||||
} else {
|
|
||||||
// Prepare the canvas path if we have any situation that
|
// Prepare the canvas path if we have any situation that
|
||||||
// requires it to be defined.
|
// requires it to be defined.
|
||||||
if (hasFill || hasStroke && !dashLength || compound || clip)
|
if (hasFill || hasStroke && !dashLength || compound || clip)
|
||||||
drawSegments(ctx, this);
|
drawSegments(ctx, this);
|
||||||
if (this._closed)
|
if (this._closed)
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
if (!compound)
|
|
||||||
this._currentPath = ctx.currentPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clip && !compound && (hasFill || hasStroke)) {
|
if (!clip && !compound && (hasFill || hasStroke)) {
|
||||||
// If the path is part of a compound path or doesn't have a fill
|
// If the path is part of a compound path or doesn't have a fill
|
||||||
|
|
Loading…
Reference in a new issue