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

fix: NativeImage.getScaleFactors returns correct scales #25832

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

nornagon
Copy link
Member

@nornagon nornagon commented Oct 8, 2020

Description of Change

Extracting part of #25727 which is safer (though doesn't fix everything that #25727 does).

gfx::ImageSkia::GetSupportedScales() is a static method that always returns the same values, regardless of the properties of the image.

Fixing this necessitated changing the CreateFromPNG function to call AddImageSkiaRepFromPNG instead of CreateFrom1xPNGBytes. The reason is that gfx::Image has some functionality for lazily decoding PNG images on an as-needed basis. When a gfx::Image is created with a PNG source, it will only materialize a representation (pixel buffer) for that image when a specific scale factor is requested. So asking for "what scale factors does this image have?" of an image created in this way, when no scale factors have already been requested, would return an empty list.

This has the downside that we now eagerly decode PNGs instead of lazily decoding them. Unfortunately, there is no way to detect the "lazy-decoding" state through the API that gfx::Image decodes. This PR chooses correctness over performance.

Checklist

Release Notes

Notes: Fixed NativeImage.getScaleFactors() always returning the same value.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Oct 8, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Oct 9, 2020
@zcbenz zcbenz merged commit cbe751d into master Oct 13, 2020
@release-clerk
Copy link

release-clerk bot commented Oct 13, 2020

Release Notes Persisted

Fixed NativeImage.getScaleFactors() always returning the same value.

@trop
Copy link
Contributor

trop bot commented Oct 13, 2020

I have automatically backported this PR to "11-x-y", please check out #25903

@trop trop bot removed the target/11-x-y label Oct 13, 2020
@trop
Copy link
Contributor

trop bot commented Oct 13, 2020

I have automatically backported this PR to "9-x-y", please check out #25904

@trop
Copy link
Contributor

trop bot commented Oct 13, 2020

I have automatically backported this PR to "10-x-y", please check out #25905

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

Successfully merging this pull request may close these issues.

None yet

4 participants