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

[api-minor] Remove the use of (get/put)ImageData when drawing SMasks (bug 1874013) #18029

Merged
merged 1 commit into from
May 1, 2024

Conversation

calixteman
Copy link
Contributor

and implement then in using some SVG filters and composition. Composing in using destination-in in order to multiply RGB components by the alpha from the mask isn't perfect: it'd be a way better to natively have alpha masks support, it induces some small rounding errors and consequently computed RGB are approximatively correct.
In term of performance, it's a real improvement, for example, the pdf in issue #17779 is now rendered in few seconds.
There are still some room for improvement, but overall it should be a way better.

@calixteman
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/0feb0b21b97d482/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/0a021c7af3d4282/output.txt

src/display/canvas.js Fixed Show fixed Hide fixed
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/0feb0b21b97d482/output.txt

Total script time: 27.54 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 65
  different first/second rendering: 2

Image differences available at: http://54.241.84.105:8877/0feb0b21b97d482/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/0a021c7af3d4282/output.txt

Total script time: 42.37 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 27

Image differences available at: http://54.193.163.58:8877/0a021c7af3d4282/reftest-analyzer.html#web=eq.log

@Snuffleupagus Snuffleupagus changed the title Remove the use of (get/put)ImageData when drawing smaks (bug 1874013) [api-minor] Remove the use of (get/put)ImageData when drawing smasks (bug 1874013) May 1, 2024
@Snuffleupagus Snuffleupagus changed the title [api-minor] Remove the use of (get/put)ImageData when drawing smasks (bug 1874013) [api-minor] Remove the use of (get/put)ImageData when drawing SMasks (bug 1874013) May 1, 2024
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

This seems generally fine, with the movement in the reference-tests inline with what you'd expect from this sort of patch (since there's mostly off-by-one changes in the pixel-values).

One thing to note, that however should not block this PR: This will "break", and essentially regress, SMask rendering in Node.js environments.
Given that the PDF.js library is still usable for general PDF parsing in Node.js, with only rendering affected, combined with Node.js being listed as "mostly" supported in the FAQ this seems fine to me.
Users affected by this should thus be encouraged to implement/polyfill (general) filter-support for Node.js environments.

src/display/display_utils.js Outdated Show resolved Hide resolved
src/display/display_utils.js Outdated Show resolved Hide resolved
src/display/canvas.js Show resolved Hide resolved
src/display/canvas.js Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/a3d493b8457d6dc/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a3d493b8457d6dc/output.txt

Total script time: 1.18 mins

Published

@Snuffleupagus Snuffleupagus linked an issue May 1, 2024 that may be closed by this pull request
@calixteman
Copy link
Contributor Author

calixteman commented May 1, 2024

One thing to note, that however should not block this PR: This will "break", and essentially regress, SMask rendering in Node.js environments.

Did you already test pdf.js with https://www.npmjs.com/package/skia-canvas ? or with CanvasKit: https://www.npmjs.com/package/canvaskit-wasm ?

CanvasKit looks interesting:
https://www.npmjs.com/package/canvaskit-wasm#drop-in-canvas2d-replacement

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented May 1, 2024

Did you already test pdf.js with https://www.npmjs.com/package/skia-canvas ? or with CanvasKit: https://www.npmjs.com/package/canvaskit-wasm ?

I've not done that, however it'd probably not help without additional work on the PDF.js side of things. (But as said above that should not block this PR, I just wanted to mention that to prevent surprises later.)

Note how nothing filter-related currently works in Node.js, since it's using

class NodeFilterFactory extends BaseFilterFactory {}

which simply extends
class BaseFilterFactory {
constructor() {
if (this.constructor === BaseFilterFactory) {
unreachable("Cannot initialize BaseFilterFactory.");
}
}
addFilter(maps) {
return "none";
}
addHCMFilter(fgColor, bgColor) {
return "none";
}
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
return "none";
}
destroy(keepHCM = false) {}
}

…(bug 1874013)

and implement then in using some SVG filters and composition.
Composing in using destination-in in order to multiply RGB components by
the alpha from the mask isn't perfect: it'd be a way better to natively have
alpha masks support, it induces some small rounding errors and consequently
computed RGB are approximatively correct.
In term of performance, it's a real improvement, for example, the pdf in
issue mozilla#17779 is now rendered in few seconds.
There are still some room for improvement, but overall it should be a way
better.
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

r=me, thank you!

@calixteman calixteman merged commit 96ce111 into mozilla:master May 1, 2024
8 of 9 checks passed
@calixteman
Copy link
Contributor Author

/botio makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/31cf2e12253af63/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/706e735560c221e/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/31cf2e12253af63/output.txt

Total script time: 19.98 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/706e735560c221e/output.txt

Total script time: 25.33 mins

  • Lint: Passed
  • Make references: FAILED

@calixteman
Copy link
Contributor Author

/botio-windows makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/adec702218bff64/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/adec702218bff64/output.txt

Total script time: 25.37 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@luckymore
Copy link

Good job, and When are we going to release it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants