-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
SVG: optimize and refactor group creation code #7715
Conversation
bf1cddd
to
351bf25
Compare
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.
That is a really good start. I think we need to backout some changes in the viewer and avoid a regression in chrome.
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf'; | ||
var scale = +queryParams.scale || 1.5; | ||
var DEFAULT_SCALE = 1.5; | ||
var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf'; |
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.
I would like to have flexibility to change file via query string during testing different files.
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.
Fixed in the new commits.
this.pgrp.appendChild(this.defs); | ||
this.pgrp.appendChild(this.tgrp); | ||
this.svg.appendChild(this.pgrp); | ||
this.svg.setAttributeNS(null, 'transform', pm(viewport.transform)); |
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.
this does not work for chrome -- we will need to create a root group and use it as this.svg ?
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.
Fixed in the new commits.
/** | ||
* @private | ||
*/ | ||
_finishGroup: function SVGGraphics_finishGroup() { |
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.
_finishGroup can be removed, see yurydelendik@f4c8099
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.
Fixed in the new commits. Nice find!
This patch: - resolves a warning in the console about missing character encoding; - makes the viewer use the same background color and PDF file as the regular viewer; - simplifies the example to bring it more in line with the other examples.
351bf25
to
90797bf
Compare
This patch ensures that we only create transformation groups when it is actually required and that we re-use transform groups as much as possible. It reduces the number of transform groups for the Tracemonkey paper from 2790 to 1271, thereby making the DOM much lighter and rendering/scrolling smoother. Moreover, it simplifies the code and prevents duplication. Finally, we issue a warning when an unimplemented graphic state is encountered. Before, this was ignored silently, making debugging harder.
Each well-formed SVG image has the following structure: SVG element - Definitions element - Root group - Other group 1 - ... - Other group n This patch factors out initialization code into a private method in such as way that the creation of this structure is clear from the code. The root group is the replacement for the parent group from before. We need this group as we cannot apply the viewport transform on the SVG element itself (this caused issues in Chrome). If other code appends groups to the SVG image, in reality it is appending those groups to the root group, but this detail is abstracted away by this patch.
90797bf
to
426fc45
Compare
I have updated the commits based on the review comments. Could you check again? |
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.
Thank you for the patch.
SVG: optimize and refactor group creation code
This patch series brings down the number of transform groups for the Tracemonkey paper from 2790 to 1271, resulting in a much lighter DOM and faster rendering/scrolling. Refer to the commit messages for more information.