Skip to content
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

Improve the Pattern-detection in CanvasGraphics.stroke #12591

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

Snuffleupagus
Copy link
Collaborator

The vast majority of the time, unless a Pattern is active, the strokeColor-property contains a "simple" colour value represented by a String. Hence it seems somewhat ridiculous to do a hasOwnProperty check on a String, and it's should thus be possible to improve things a tiny bit here.

Unfortunately using a simple instanceof check would only work for TilingPatterns, but not for the ShadingIRs given how they are implemented; see src/display/pattern_helper.js. (While that file could probably do with some clean-up, given the age of some of its code, that probably shouldn't happen here.)

Finally, the this.type = "Pattern"-property of the various Shadings/TilingPatterns were removed, since I cannot see why it's necessary when we can simply check for a getPattern method instead. Note that part of this code even pre-dates the main/worker-thread split, which probably in part explains why it looks the way it does.

The vast majority of the time, unless a Pattern is active, the `strokeColor`-property contains a "simple" colour value represented by a String. Hence it seems somewhat ridiculous to do a `hasOwnProperty` check on a String, and it's should thus be possible to improve things a tiny bit here.

Unfortunately using a simple `instanceof` check would only work for `TilingPattern`s, but not for the `ShadingIRs` given how they are implemented; see `src/display/pattern_helper.js`. (While that file could probably do with some clean-up, given the age of some of its code, that probably shouldn't happen here.)

Finally, the `this.type = "Pattern"`-property of the various Shadings/TilingPatterns were removed, since I cannot see why it's necessary when we can simply check for a `getPattern` method instead. Note that part of this code even pre-dates the main/worker-thread split, which probably in part explains why it looks the way it does.
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2020

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8abb60f67a7260c/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2020

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://3.101.106.178:8877/d88eca80a52c05f/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2020

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/8abb60f67a7260c/output.txt

Total script time: 25.06 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/8abb60f67a7260c/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2020

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/d88eca80a52c05f/output.txt

Total script time: 28.46 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://3.101.106.178:8877/d88eca80a52c05f/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit e3851a6 into mozilla:master Nov 6, 2020
@timvandermeij
Copy link
Contributor

Thank you for simplifying this a bit!

@Snuffleupagus Snuffleupagus deleted the strokeColor-Pattern branch November 7, 2020 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants