-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Impeller] Use separate atlases and shaders for color and alpha #41780
[Impeller] Use separate atlases and shaders for color and alpha #41780
Conversation
Still need to investigate if this fixes flutter/flutter#126101 . EDIT: it does |
Skia seems to correct the alpha based on the paint color. I think the AA alpha dropoff becomes more aggressive as the color gets darker. |
We have it tuned to draw black text on a white background right now because black text that's too thick looks worse/more jarring than white text that's too thin. |
Note that I did not actually change how glyphs are rendered, except in the case where there are emoji present - then previously we would promote to a full color atlas. Upon checking, it does appear that dark text gets darker, but the rendering is indentical in the case where there is no emoji. So not exactly regressed, but not quite fixed yet. Let me double check the color that is being using in Skia. Skia only uses a single color in their atlas regardless of light/dark background so we should be able to also. |
Though it looks the same if I always use SK_ColorWHITE? |
Skia's internal atlas (assuming it's actually storing one) is probably not going to have the color-based alpha correction applied to it, lest they would have to generate different glyphs based on a color source state hash. My guess would be that the alpha is linear in their internal atlas. Then, when they sample it, they just map it through a simple curve (like an exponential that's tuned based on some computed property of the color -- like brightness). |
I don't think they're doing that. Here is the text fragment shader that gets generated:
They have an R8 glyph atlas with at scale rendered glyphs, and the sampler is a NN sampler |
Anyway, it turns out this does not fix the light text on dark background - and we're still bolder than Skia on the same font. |
SkPaint glyph_paint; | ||
glyph_paint.setColor(glyph_color); | ||
glyph_paint.setColor(SK_ColorWHITE); |
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 needs to always be SK_ColorWhite, otherwise we end up darkening the dark text on light backgrounds. However this change does fix the issue that non-color glyphs were inconsistently rendered depending on whether or not we had promoted the atlas to full color.
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.
IIUC, this is going to make white text look correct, but black text look too thick, regressing the more common cases solved for in flutter/flutter#119805 and flutter/flutter#119234.
In this case, it's probably getting baked in when the atlas is generated? I assume different subpixel AA variations of the same glyph are also getting baked into the atlas with this solution.
You mean text looks thinner than Skia for light text with a dark background, right? Black text on a white background should look nearly identical to Skia at ToT. |
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
(but of course I need to figure out if the goldens got thinner (expected) or thicker (unexpected)) |
My worry is about the behavior of text drawn to the U8 atlas before and after this PR. I haven't tried running this PR yet, but my expectation is that all text drawn to the U8 atlas will become thicker, regressing flutter/flutter#119805 and flutter/flutter#119234. |
Put the color atlas check back, just in case we need it. I've also confirmed that with the color changed back we haven't adjusted how font was rendered provided that we were already using the A8 atlas . Fonts should still be thinner in general if they were included in the full color atlas before. None of our goldens cover this specific case though. cast.2.webmcast.3.webm |
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.
LGTM!
…sions) (#126455) Manual roll requested by aaclarke@google.com Cannot build log URL because revision "892f88d2513f" is invalid: Luci builds of "Linux Fuchsia FEMU" for 892f88d2513f4a60ebd6d1496c4ac272e53c55ba was STARTED 2023-05-10 zanderso@users.noreply.github.com Revert "Move linux fuchsia engine v2 build to prod." (flutter/engine#41902) 2023-05-10 godofredoc@google.com Migrate mac host clang tidy to engine v2. (flutter/engine#41824) 2023-05-10 jonahwilliams@google.com [Impeller] delete special handling of RRect. (flutter/engine#41872) 2023-05-10 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JiOACcaGrDphuHIql... to a3rrULFaXlwS8mfjW... (flutter/engine#41898) 2023-05-10 109111084+yaakovschectman@users.noreply.github.com Only register top level window message listener upon registering service binding (flutter/engine#41733) 2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 8c936fb9ba8e to 32f4cfc2460b (27 revisions) (flutter/engine#41891) 2023-05-10 yjbanov@google.com [web] dialog a11y fixes (flutter/engine#41681) 2023-05-10 skia-flutter-autoroll@skia.org Roll Dart SDK from 2cf089614e1c to 7ad028c26344 (2 revisions) (flutter/engine#41882) 2023-05-10 jonahwilliams@google.com [Impeller] Increase minimum size of alpha glyph atlas. (flutter/engine#41880) 2023-05-10 jonahwilliams@google.com [Impeller] Use separate atlases and shaders for color and alpha (flutter/engine#41780) 2023-05-10 godofredoc@google.com Move linux fuchsia engine v2 build to prod. (flutter/engine#41865) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JiOACcaGrDph to a3rrULFaXlwS If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…126468) flutter/engine@10ac36c...406b354 2023-05-10 mdebbar@google.com [web] Re-enable history tests on Safari (flutter/engine#41901) 2023-05-10 flar@google.com switch from MockCanvas to DisplayListBuilder in layer unit tests (flutter/engine#41889) 2023-05-10 zanderso@users.noreply.github.com Revert "Move linux fuchsia engine v2 build to prod." (flutter/engine#41902) 2023-05-10 godofredoc@google.com Migrate mac host clang tidy to engine v2. (flutter/engine#41824) 2023-05-10 jonahwilliams@google.com [Impeller] delete special handling of RRect. (flutter/engine#41872) 2023-05-10 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JiOACcaGrDphuHIql... to a3rrULFaXlwS8mfjW... (flutter/engine#41898) 2023-05-10 109111084+yaakovschectman@users.noreply.github.com Only register top level window message listener upon registering service binding (flutter/engine#41733) 2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 8c936fb9ba8e to 32f4cfc2460b (27 revisions) (flutter/engine#41891) 2023-05-10 yjbanov@google.com [web] dialog a11y fixes (flutter/engine#41681) 2023-05-10 skia-flutter-autoroll@skia.org Roll Dart SDK from 2cf089614e1c to 7ad028c26344 (2 revisions) (flutter/engine#41882) 2023-05-10 jonahwilliams@google.com [Impeller] Increase minimum size of alpha glyph atlas. (flutter/engine#41880) 2023-05-10 jonahwilliams@google.com [Impeller] Use separate atlases and shaders for color and alpha (flutter/engine#41780) 2023-05-10 godofredoc@google.com Move linux fuchsia engine v2 build to prod. (flutter/engine#41865) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JiOACcaGrDph to a3rrULFaXlwS If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…sions) (flutter#126455) Manual roll requested by aaclarke@google.com Cannot build log URL because revision "892f88d2513f" is invalid: Luci builds of "Linux Fuchsia FEMU" for 892f88d2513f4a60ebd6d1496c4ac272e53c55ba was STARTED 2023-05-10 zanderso@users.noreply.github.com Revert "Move linux fuchsia engine v2 build to prod." (flutter/engine#41902) 2023-05-10 godofredoc@google.com Migrate mac host clang tidy to engine v2. (flutter/engine#41824) 2023-05-10 jonahwilliams@google.com [Impeller] delete special handling of RRect. (flutter/engine#41872) 2023-05-10 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JiOACcaGrDphuHIql... to a3rrULFaXlwS8mfjW... (flutter/engine#41898) 2023-05-10 109111084+yaakovschectman@users.noreply.github.com Only register top level window message listener upon registering service binding (flutter/engine#41733) 2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 8c936fb9ba8e to 32f4cfc2460b (27 revisions) (flutter/engine#41891) 2023-05-10 yjbanov@google.com [web] dialog a11y fixes (flutter/engine#41681) 2023-05-10 skia-flutter-autoroll@skia.org Roll Dart SDK from 2cf089614e1c to 7ad028c26344 (2 revisions) (flutter/engine#41882) 2023-05-10 jonahwilliams@google.com [Impeller] Increase minimum size of alpha glyph atlas. (flutter/engine#41880) 2023-05-10 jonahwilliams@google.com [Impeller] Use separate atlases and shaders for color and alpha (flutter/engine#41780) 2023-05-10 godofredoc@google.com Move linux fuchsia engine v2 build to prod. (flutter/engine#41865) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JiOACcaGrDph to a3rrULFaXlwS If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#126468) flutter/engine@10ac36c...406b354 2023-05-10 mdebbar@google.com [web] Re-enable history tests on Safari (flutter/engine#41901) 2023-05-10 flar@google.com switch from MockCanvas to DisplayListBuilder in layer unit tests (flutter/engine#41889) 2023-05-10 zanderso@users.noreply.github.com Revert "Move linux fuchsia engine v2 build to prod." (flutter/engine#41902) 2023-05-10 godofredoc@google.com Migrate mac host clang tidy to engine v2. (flutter/engine#41824) 2023-05-10 jonahwilliams@google.com [Impeller] delete special handling of RRect. (flutter/engine#41872) 2023-05-10 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JiOACcaGrDphuHIql... to a3rrULFaXlwS8mfjW... (flutter/engine#41898) 2023-05-10 109111084+yaakovschectman@users.noreply.github.com Only register top level window message listener upon registering service binding (flutter/engine#41733) 2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 8c936fb9ba8e to 32f4cfc2460b (27 revisions) (flutter/engine#41891) 2023-05-10 yjbanov@google.com [web] dialog a11y fixes (flutter/engine#41681) 2023-05-10 skia-flutter-autoroll@skia.org Roll Dart SDK from 2cf089614e1c to 7ad028c26344 (2 revisions) (flutter/engine#41882) 2023-05-10 jonahwilliams@google.com [Impeller] Increase minimum size of alpha glyph atlas. (flutter/engine#41880) 2023-05-10 jonahwilliams@google.com [Impeller] Use separate atlases and shaders for color and alpha (flutter/engine#41780) 2023-05-10 godofredoc@google.com Move linux fuchsia engine v2 build to prod. (flutter/engine#41865) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JiOACcaGrDph to a3rrULFaXlwS If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Creates a separate atlas context and cache for color and alpha bitmap glyphs. Removes SDF shader and uses separate shader for full color glyphs.
Requires #41754
Fixes flutter/flutter#116818
Fixes flutter/flutter#126101
This also fixes #39383 but for light text on a dark background. This problem crops up when we switch to a full color atlas. In this context, the chosen glyph color is important. But with the alpha channel only atlas, its irrelevant.
See diff:
Example app: