-
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
Fix color of image masks inside uncolored patterns #8808
Conversation
src/display/pattern_helper.js
Outdated
@@ -360,7 +360,7 @@ var TilingPattern = (function TilingPatternClosure() { | |||
var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); | |||
graphics.groupLevel = owner.groupLevel; | |||
|
|||
this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color); | |||
this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color, graphics); |
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.
let's change signature to setFillAndStrokeStyleToGraphics(graphic, paintType, color) -- context
is accessible via graphics.ctx.
src/display/pattern_helper.js
Outdated
@@ -412,6 +413,8 @@ var TilingPattern = (function TilingPatternClosure() { | |||
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); | |||
context.fillStyle = cssColor; | |||
context.strokeStyle = cssColor; | |||
// Set color needed by image masks (fixes issues 3226 and 8741). | |||
graphics.current.fillColor = cssColor; |
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.
do we need to do that for this.current.strokeColor =
? do we need to do the same for PaintType.COLORED case?
I don't know if any PDF would need this but I added it, just to be sure.
I added lines similar to the other case. Colored tiling patterns are a bit different: now the |
/botio-linux preview |
/botio test |
I added the test case. By the way, my patch seems to fix also issue #8860. |
Thank you; one question though, wouldn't it be enough to just test the first page of the document? |
/botio test |
@janpe2 Looking at the test logs above, it appears that the server prevented the PDF file from being downloaded:
Would it be possible to link to the PDF file through e.g. https://archive.org/web/ instead, or do we need to use another PDF file for the test-case? Edit: This prevents the new test-case from actually running, with messages such as:
|
/botio test |
What are those failed regression tests? Should I be worried about them? |
The problem is that the old file is not replaced. @yurydelendik Could you remove the old (cached) |
I don't think that's going to help much, since the (Internet Archive) link does not actually point to a PDF file. It seems to me that linking to this particular PDF file will probably not work, and that the easiest solution here would be to try and use a PDF file from one of the other referenced issues as a test-case instead. |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/d3ecbe51f41b9e9/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/6b875cc3ee3d9bb/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/d3ecbe51f41b9e9/output.txt Total script time: 16.55 mins
|
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/6b875cc3ee3d9bb/output.txt Total script time: 29.73 mins
Image differences available at: http://54.215.176.217:8877/6b875cc3ee3d9bb/reftest-analyzer.html#web=eq.log |
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.
Looks good, thank you for the patch!
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/c5a69837639ea9f/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.215.176.217:8877/ebe8b13be2ac83a/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/c5a69837639ea9f/output.txt Total script time: 15.65 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/ebe8b13be2ac83a/output.txt Total script time: 28.13 mins
|
Fix color of image masks inside uncolored patterns
Fixes #8741
Fixes #3226
Fixes #8860
This is a patch for uncolored (
/PaintType 2
) tiling patterns that contain image masks. When uncolored patterns are used as a fill or stroke, the operatorscn
orSCN
specifies the color of the pattern. If the pattern contains an image mask, PDF.js incorrectly draws it using black instead of the color specified byscn
orSCN
.In my patch, I assign the proper color to the
fillColor
property of theCanvasExtraState
object. That property is used as the color of image masks in functionspaintImageMaskXObject...()
in canvas.js.