Skip to content

Commit

Permalink
Merge pull request #2083 from asturur/changes-in-rendering
Browse files Browse the repository at this point in the history
Changes in rendering
  • Loading branch information
kangax committed Apr 6, 2015
2 parents caaa99b + e15fcd4 commit 5f988a2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/shapes/group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@

ctx.save();
this.clipTo && fabric.util.clipContext(this, ctx);

this.transform(ctx);
// the array is now sorted in order of highest first, so start from end
for (var i = 0, len = this._objects.length; i < len; i++) {
this._renderObject(this._objects[i], ctx);
Expand Down
6 changes: 0 additions & 6 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,6 @@
* @param {Boolean} fromLeft When true, context is transformed to object's top/left corner. This is used when rendering text on Node
*/
transform: function(ctx, fromLeft) {
if (this.group) {
this.group.transform(ctx, fromLeft);
}
var center = fromLeft ? this._getLeftTopCoords() : this.getCenterPoint();
ctx.translate(center.x, center.y);
ctx.rotate(degreesToRadians(this.angle));
Expand Down Expand Up @@ -971,9 +968,6 @@
}
this._setStrokeStyles(ctx);
this._setFillStyles(ctx);
if (this.group && this.group.type === 'path-group') {
ctx.translate(-this.group.width/2, -this.group.height/2);
}
if (this.transformMatrix) {
ctx.transform.apply(ctx, this.transformMatrix);
}
Expand Down
3 changes: 0 additions & 3 deletions src/shapes/path.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,6 @@
}
this._setStrokeStyles(ctx);
this._setFillStyles(ctx);
if (this.group && this.group.type === 'path-group') {
ctx.translate(-this.group.width / 2, -this.group.height / 2);
}
if (this.transformMatrix) {
ctx.transform.apply(ctx, this.transformMatrix);
}
Expand Down
7 changes: 3 additions & 4 deletions src/shapes/path_group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@

ctx.save();

var m = this.transformMatrix;

if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
if (this.transformMatrix) {
ctx.transform.apply(ctx, this.transformMatrix);
}
this.transform(ctx);

this._setShadow(ctx);
this.clipTo && fabric.util.clipContext(this, ctx);
ctx.translate(-this.width/2, -this.height/2);
for (var i = 0, l = this.paths.length; i < l; ++i) {
this.paths[i].render(ctx, true);
}
Expand Down
7 changes: 1 addition & 6 deletions src/shapes/text.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,10 @@
}
this._setStrokeStyles(ctx);
this._setFillStyles(ctx);
var isInPathGroup = this.group && this.group.type === 'path-group';

if (isInPathGroup) {
ctx.translate(-this.group.width/2, -this.group.height/2);
}
if (this.transformMatrix) {
ctx.transform.apply(ctx, this.transformMatrix);
}
if (isInPathGroup) {
if (this.group && this.group.type === 'path-group') {
ctx.translate(this.left, this.top);
}
this._render(ctx);
Expand Down

1 comment on commit 5f988a2

@asturur
Copy link
Member

@asturur asturur commented on 5f988a2 Apr 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kangax i was thinking back to this commit.

this commit is still fine if we want to render individual object one by one ( for dirty rect checking for example) but this commit won t allow to render individually an object that is inside a group without rendering the group before it, because the group transform is not set.

is this fine for you?

Please sign in to comment.