Improve clipping mask drawing, and remove some unneeded ctx.save() / ctx.restore() calls.

This commit is contained in:
Jürg Lehni 2012-11-06 20:14:21 -08:00
parent 1581d44c06
commit f110038104
2 changed files with 9 additions and 9 deletions

View file

@ -120,15 +120,17 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
param.compound = true; param.compound = true;
for (var i = 0, l = children.length; i < l; i++) for (var i = 0, l = children.length; i < l; i++)
Item.draw(children[i], ctx, param); Item.draw(children[i], ctx, param);
if (this._clipMask)
ctx.clip();
param.compound = false; param.compound = false;
if (this._clipMask) {
ctx.clip();
} else {
this._setStyles(ctx); this._setStyles(ctx);
if (style._fillColor) if (style._fillColor)
ctx.fill(); ctx.fill();
if (style._strokeColor) if (style._strokeColor)
ctx.stroke(); ctx.stroke();
} }
}
}, new function() { // Injection scope for PostScript-like drawing functions }, new function() { // Injection scope for PostScript-like drawing functions
/** /**
* Helper method that returns the current path and checks if a moveTo() * Helper method that returns the current path and checks if a moveTo()

View file

@ -1489,7 +1489,6 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
} else if (!param.compound && (fillColor || strokeColor)) { } else if (!param.compound && (fillColor || strokeColor)) {
// 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
// or stroke, there is no need to continue. // or stroke, there is no need to continue.
ctx.save();
this._setStyles(ctx); this._setStyles(ctx);
if (fillColor) if (fillColor)
ctx.fill(); ctx.fill();
@ -1509,7 +1508,6 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
} }
ctx.stroke(); ctx.stroke();
} }
ctx.restore();
} }
}, },