-
Notifications
You must be signed in to change notification settings - Fork 89
Don't multiply SVG size by device pixel ratio #84
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
Conversation
@cwillisf I ran a quick benchmark on this animation, and this change reduces RAM usage on pixel-ratio 2 devices (e.g. mobile devices) by around 40%: |
@thisandagain Any update on this? This would save a substantial amount of RAM on mobile devices (see above), especially once scratchfoundation/scratch-render#431 is merged. |
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 looks great, thanks!
It looks like with this change, calls to _draw caused by setSVG in scratch-render no longer take into account device pixel density. However, I think that those calls are unnecessary, since they are immediately overwritten by a call to _draw started by _step in vm. So I've opened scratchfoundation/scratch-render#518
….0-prerelease.20191031221353 Update scratch-svg-renderer to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84
….0-prerelease.20191031221353 Update scratch-svg-renderer to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84
…2.0-prerelease.20191031221353 Update scratch-svg-renderer to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84
…release.20191101193358 Update scratch-paint to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84 via paint
…erelease.20191101193213 Update scratch-render to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84 via render
….0-prerelease.20191031221353 Update scratch-svg-renderer to the latest version 🚀 brings in scratchfoundation/scratch-svg-renderer#84
Proposed Changes
This changes SvgRenderer so that, when told to draw an SVG at a certain scale, it doesn't multiply the scale by the device pixel ratio.
Reason for Changes
The WebGLRenderer already handles all the device pixel ratio stuff [EDIT: here], and passes the SvgRenderer the proper scale for the device. By enlarging the SVGs here as well, the SvgRenderer makes them too high-resolution. If on a device with pixel ratio 2, for instance, rendered SVGs will be 4 times as large in each dimension instead of 2, and on a device with pixel ratio 3, they will be 9 times as large instead of 3.
This causes jaggies from downscaling, reduces graphics performance, and wastes VRAM.