Skip to content

Commit

Permalink
fix ericdrowell#785: cache scaled twice in scaled canvas.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzhdev committed Jan 31, 2014
1 parent da28418 commit 4da39ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
clipY = this.getClipY();

context.save();
context._applyTransform(this);
context._applyTransform(this, canvas.isCache);
context.beginPath();
context.rect(clipX, clipY, clipWidth, clipHeight);
context.clip();
Expand Down
9 changes: 7 additions & 2 deletions src/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,17 @@
this.setAttr('lineJoin', lineJoin);
}
},
_applyTransform: function(shape) {
_applyTransform: function(shape, isCacheCanvas) {
var transformsEnabled = shape.getTransformsEnabled(),
m;

if (transformsEnabled === 'all') {
m = shape.getAbsoluteTransform().getMatrix();
if (isCacheCanvas) {
// don't apply parents' transform on cache canvas
m = shape.getTransform().getMatrix();
} else {
m = shape.getAbsoluteTransform().getMatrix();
}
this.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
else if (transformsEnabled === 'position') {
Expand Down
3 changes: 3 additions & 0 deletions src/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
origY = this.y(),
sceneContext;

cachedSceneCanvas.isCache = true;
cachedHitCanvas.isCache = true;

this.clearCache();

this.transformsEnabled('position');
Expand Down
6 changes: 3 additions & 3 deletions src/Shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
bufferContext.clear();
bufferContext.save();
bufferContext._applyLineJoin(this);
bufferContext._applyTransform(this);
bufferContext._applyTransform(this, canvas.isCache);

drawFunc.call(this, bufferContext);
bufferContext.restore();
Expand All @@ -172,7 +172,7 @@
// if buffer canvas is not needed
else {
context._applyLineJoin(this);
context._applyTransform(this);
context._applyTransform(this, canvas.isCache);

if (hasShadow) {
context.save();
Expand Down Expand Up @@ -205,7 +205,7 @@
else if (drawFunc) {
context.save();
context._applyLineJoin(this);
context._applyTransform(this);
context._applyTransform(this, canvas.isCache);

drawFunc.call(this, context);
context.restore();
Expand Down

0 comments on commit 4da39ed

Please sign in to comment.