-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shading-pattern: While drawing patterns, use transform to baseTransform first #6684
shading-pattern: While drawing patterns, use transform to baseTransform first #6684
Conversation
This PR should be ready now. I'll squash the commits on request. |
@@ -1839,7 +1839,7 @@ | |||
"link": false, | |||
"type": "load", | |||
"password": "\u00E6\u00F8\u00E5", | |||
"about": "The password (���) is UTF8 encoded." | |||
"about": "The password (���) is UTF8 encoded." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-o
I have not yet looked into the following: I applied the change in |
@dsprenkels Could you squash the commits? Looking at the diff in https://github.com/mozilla/pdf.js/pull/6684/files, I don't see how the |
I dabbled trying to revert the transformation, but as you say, I believe I have the "wrong" I have seen, however, that this bug not only occurs in ctx.save();
// (...)
var m = this.baseTransform;
ctx.setTransform(m[0], m[1], m[2], m[3], m[4], m[5]);
// (...) the stroke width is not correct anymore, (and I am not sure if other variables may be influenced as well). The method I use in https://github.com/dsprenkels/pdf.js/commit/e5adbf62c37a964824b40fc52243acbd87eff05b is bad (but illustrates the idea of reverting the transformation done by the |
This patch completely fixes #6296, #6486, #6293 (except for the last PDF which will become a separate issue) and #5436. It largely fixes #6298. Let's revert to the situation before the latest changes as that seems a reasonable way to fix this issue. Other methods can be updated in a follow-up patch, as it would be good to land this since it fixes a bunch of issues. You can always contact us in IRC to discuss this patch. |
@timvandermeij |
@@ -1089,6 +1089,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||
|
|||
if (isPatternFill) { | |||
ctx.save(); | |||
var m = this.baseTransform || | |||
this.ctx.mozCurrentTransform.slice(); | |||
ctx.setTransform(m[0], m[1], m[2], m[3], m[4], m[5]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this code just performs: if (this.baseTransform) { ctx.setTransform.apply(ctx, this.baseTransform); }
? (Now I wonder if we ever will get this.baseTransform == null
.)
I don't think you need to perform this.ctx.mozCurrentTransform and its slicing -- it will just create unneeded objects.
Shall stroke have the same statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this code just performs: if (this.baseTransform) { ctx.setTransform.apply(ctx, this.baseTransform); }? (Now I wonder if we ever will get this.baseTransform == null.)
I initially just used this.baseTransform
, got null
in some test cases from the test suite, and saw that in other places the expression this.baseTransform || this.ctx.mozCurrentTransform.slice();
was used. I did not know that the current tranformation was actually stored in this.ctx.mozCurrentTransform
, (although now it makes a lot of sense).
You are right that this piece of code could better be if (this.baseTransform) { ctx.setTransform.apply(ctx, this.baseTransform); }
.
Shall stroke have the same statements?
I some manner of speaking: "Yes". However, when transforming the stroke, the stroke width would be transformed as well. I do not know if other side effects occur when using ctx.setTransform()
, that's why I initially thought that it may be a better idea to not use ctx.save()
and ctx.restore()
, but to alter the matrices of the patterns directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the stroke width would be transformed as well
IMHO if it needs to be done, then we shall do it.
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/20102b3966f74cd/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/20102b3966f74cd/output.txt Total script time: 0.84 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/57736848603eae8/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/bb7ed3406c1e2d8/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/bb7ed3406c1e2d8/output.txt Total script time: 20.22 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/57736848603eae8/output.txt Total script time: 20.27 mins
|
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/f119b893fd27fd1/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/f2b78b29f43227d/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/f119b893fd27fd1/output.txt Total script time: 19.33 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/f2b78b29f43227d/output.txt Total script time: 19.64 mins
|
shading-pattern: While drawing patterns, use transform to baseTransform first
Thank you for the fix! |
This also fixes https://bugzilla.mozilla.org/show_bug.cgi?id=870041. |
This also fixed https://bugzilla.mozilla.org/show_bug.cgi?id=1105594. |
I propose a fix for issue #6296.
I am, however, a bit uncertain about the implementation: maybe it would be better to alter the coordinates directly, instead of using
ctx.save()
andctx.restore()
. (Or maybe doing this inRadialAxialClosure
).