-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Fixed translated text's subpixel alignment. #162824
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
3cd5c84
to
037a0af
Compare
There is some cleanup that needs to come to the font rendering code. I'm not happy with how this is all laid out but this is the minimal change to fix the issue. We can consider refactors later.
|
|
||
// Checks that the left most edge of the glyph is fading out as we push | ||
// it to the right by fractional pixels. | ||
TEST_P(DlGoldenTest, SubpixelScaledTranslated) { |
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 is the test that would actually fail before this change, the other passed.
@@ -452,7 +452,8 @@ TypographerContextSkia::CollectNewGlyphs( | |||
for (const auto& glyph_position : run.GetGlyphPositions()) { | |||
Point subpixel = TextFrame::ComputeSubpixelPosition( | |||
glyph_position, scaled_font.font.GetAxisAlignment(), | |||
frame->GetOffset(), frame->GetScale()); | |||
frame->GetTransform() * | |||
Matrix::MakeTranslation(frame->GetOffset())); |
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 is annoying, the transform here doesn't include the offset, but when you go to render it in TextContents it has the offset included.
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!
const uint32_t* ptr = reinterpret_cast<const uint32_t*>(img->GetBytes()); | ||
for (size_t i = 0; i < img->GetHeight(); ++i) { | ||
for (int32_t j = 0; j < static_cast<int32_t>(img->GetWidth()); ++j) { | ||
if (((*ptr & 0x00ffffff) != 0)) { |
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.
yes, of course
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.
indeed, sir
Weird, something is going on with the vulkan renderer where we are getting zero values in the blue channel. We should look into that. For now I switched to the green channel which works as expected locally. |
autosubmit label was removed for flutter/flutter/162824, because - The status or check suite Mac mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
autosubmit label was removed for flutter/flutter/162824, because - The status or check suite Linux linux_web_engine_tests has failed. Please fix the issues identified (or deflake) before re-applying this label. |
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. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
fixes flutter#162776 fixes flutter#149652 Previously we weren't calculating the subpixel offset correctly. We weren't using the transform of the object being drawn to get global coordinates, now we are. ## Video of flutter#149652 after PR https://github.com/user-attachments/assets/3e9063d5-f70c-46d0-a7a4-892819b247b8 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
fixes flutter#162776 fixes flutter#149652 Previously we weren't calculating the subpixel offset correctly. We weren't using the transform of the object being drawn to get global coordinates, now we are. ## Video of flutter#149652 after PR https://github.com/user-attachments/assets/3e9063d5-f70c-46d0-a7a4-892819b247b8 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This is a cherry-pick for all the changes that went into fixing #149652 It looks like a lot but most of it is testing and refactoring. ## PRs included - #161625 - #162351 - #162415 - #162555 - #162824 ## Impacted Users All users of Impeller. ## Impact Description Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales ## Workaround Use skia. ## Risk Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. ## Test Coverage Yes. ## Validation Steps The reproduction code in #149652 is good.
This is a cherry-pick for all the changes that went into fixing flutter#149652 It looks like a lot but most of it is testing and refactoring. - flutter#161625 - flutter#162351 - flutter#162415 - flutter#162555 - flutter#162824 All users of Impeller. Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales Use skia. Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. Yes. The reproduction code in flutter#149652 is good.
This is a cherry-pick for all the changes that went into fixing flutter/flutter#149652 It looks like a lot but most of it is testing and refactoring. ## PRs included - flutter/flutter#161625 - flutter/flutter#162351 - flutter/flutter#162415 - flutter/flutter#162555 - flutter/flutter#162824 ## Impacted Users All users of Impeller. ## Impact Description Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales ## Workaround Use skia. ## Risk Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. ## Test Coverage Yes. ## Validation Steps The reproduction code in flutter/flutter#149652 is good.
fixes #162776
fixes #149652
Previously we weren't calculating the subpixel offset correctly. We weren't using the transform of the object being drawn to get global coordinates, now we are.
Video of #149652 after PR
gotit.mov
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.