-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Fix text glyph bounds on Android. #43919
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| SkScalar x, | ||
| SkScalar y) { | ||
| const auto text_frame = TextFrameFromTextBlob(blob); | ||
| const auto text_frame = TextFrameFromTextBlob( |
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 wonder if this will work against @dnfield s work to defer computing the text scale. Seems like this is strictly an improvement for now, but we should probably also defer the initial scale value?
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.
Yeah, good catch. Using the scale here could indeed cause problems. Text frames drawn through DrawPicture might not end up having precise enough glyph bounds depending on how much the elements of the picture get scaled up.
We can get away with just using a decently large number here instead of the scale, so I went ahead and removed the usage and checked to make sure it's still working with unreasonably huge glyphs on Android.
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.
After doing this, there are no longer any overlapping characters in the MaybeHasOverlapping test. The accompanying comment was:
Characters probably have overlap due to low fidelity text metrics, but this could be fixed.
So if there happens to be an accompanying bug I guess we can close that too. :)
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.
Ahh interesting. So we don't actually end up rasterizing at a higher scale, we're essentially just tricking Skia into giving higher fidelity metrics.
I don't think I filed a bug for that particular overlap issue, I would update the expectation and delete the TODO.
aee636b to
33586eb
Compare
33586eb to
7750000
Compare
|
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. |
jonahwilliams
left a comment
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
|
There are no golden changes listed. ¯_(ツ)_/¯ Merging this. |
…131136) flutter/engine@30f0f6b...4ad970f 2023-07-22 [email protected] [Impeller] Fix text glyph bounds on Android. (flutter/engine#43919) 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 [email protected],[email protected],[email protected] 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#131136) flutter/engine@30f0f6b...4ad970f 2023-07-22 [email protected] [Impeller] Fix text glyph bounds on Android. (flutter/engine#43919) 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 [email protected],[email protected],[email protected] 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#131136) flutter/engine@30f0f6b...4ad970f 2023-07-22 [email protected] [Impeller] Fix text glyph bounds on Android. (flutter/engine#43919) 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 [email protected],[email protected],[email protected] 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
Resolves flutter/flutter#128624.
It turns out that
SkFont::getBounds()snaps results to integers on Android, but not iOS. By scaling the font up and scaling the resulting per-glyph bounds back down, we can ensure that the results are always precise enough.I also found errors with our usage of the computed bounds, but those were comparatively minor fixes.
Before:
before.mp4
After:
after.mp4
Minimal repro app: