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

[Impeller] Improve resolution of text scaling. #43533

Merged
merged 8 commits into from
Jul 11, 2023

Conversation

dnfield
Copy link
Contributor

@dnfield dnfield commented Jul 10, 2023

This patch does a few things:

  • Changes ownership of the LazyGlyphAtlas to ContentContext from Canvas. This means that drawings with multiple canvases (e.g. calls to DrawPicture) share the same lazy atlas.
  • Moves the scale property from Font::Metrics to FontGlyphPair. Font::Metrics contains properties related to the font, whereas scale has to do with the properties of the drawing at render time and is independent of the font.
  • Makes the lazy atlas manage FontGlyphPair::Set rather than vectors of TextFrames.
  • Makes the determination of font scaling at EntityPass::Render rather than Canvas::DrawTextFrame. The scaling may be altered by calls to Canvas::DrawPicture by render time and otherwise get missed. This is done via a new method: Contents::PopulateGlyphAtlas, which is only implemented by TextContents in this patch.
  • Fixes up some miscelleaneous bugs in Font::Metrics hashing and unused/dead code.

This improves over prior attempts: LazyGlyphAtlas ownership is now unambiguous, and glyph scaling happens correctly for all rendered glyphs regardless of the order of canvas operations in Aiks.

Fixes flutter/flutter#130142

This patch does a few things:

- Changes ownership of the LazyGlyphAtlas to ContentContext from
  Canvas. This means that drawings with multiple canvases (e.g.
  calls to DrawPicture) share the same lazy atlas.
- Moves the scale property from Font::Metrics to FontGlyphPair.
  Font::Metrics contains properties related to the font, whereas
  scale has to do with the properties of the drawing at render time
  and is independent of the font.
- Makes the lazy atlas manage FontGlyphPair::Set rather than
  vectors of TextFrames.
- Makes the determination of font scaling at EntityPass::Render
  rather than Canvas::DrawTextFrame. The scaling may be altered
  by calls to Canvas::DrawPicture by render time and otherwise
  get missed. This is done via a new method:
  Contents::PopulateGlyphAtlas, which is only implemented by
  TextContents in this patch.

This improves over prior attempts: LazyGlyphAtlas ownership is now
unambiguous, and glyph scaling happens correctly for all rendered
glyphs regardless of the order of canvas operations in Aiks.

Fixes flutter/flutter#130142
Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach LGTM, assuming there are no serious performance changes on apps with large numbers of entities.

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 10, 2023

auto label is removed for flutter/engine, pr: 43533, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

auto type = frame_.GetAtlasType();
auto scale = entity.GetTransformation().GetMaxBasisLengthXY();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Might make sense to have a static Scalar TextContents::DeriveTextScaleFromEntity(const Entity& entity) const or maybe even Scalar Entity::DeriveTextScale() const and use that in both spots. Our way of computing the scale has changed a few times.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -376,23 +351,23 @@ std::shared_ptr<GlyphAtlas> TextRenderContextSkia::CreateGlyphAtlas(
// added.

// ---------------------------------------------------------------------------
// Step 4: Record the positions in the glyph atlas of the newly added
// Step 3a: Record the positions in the glyph atlas of the newly added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why the as and bs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there are two branches that go down here that both were reusing the same step numbers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, makes sense.

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 10, 2023

auto label is removed for flutter/engine, pr: 43533, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Mac mac_clang_tidy has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Linux linux_clang_tidy has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 10, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 10, 2023

auto label is removed for flutter/engine, pr: 43533, due to - The status or check suite Linux linux_arm_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 11, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 11, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 11, 2023

auto label is removed for flutter/engine, pr: 43533, due to - The status or check suite Mac mac_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 11, 2023
@flutter-dashboard
Copy link

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.

Changes reported for pull request #43533 at sha 1dc36de

@auto-submit auto-submit bot merged commit 767f2fb into flutter:main Jul 11, 2023
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 11, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 11, 2023
…130313)

flutter/engine@153d9e1...767f2fb

2023-07-11 dnfield@google.com [Impeller] Improve resolution of text scaling. (flutter/engine#43533)

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
@dnfield dnfield deleted the tc_scale_3 branch July 13, 2023 16:13
auto-submit bot pushed a commit that referenced this pull request Jul 13, 2023
Reverts  #43533
Cause of flutter/flutter#130476

I was trying to add a test for this but it's taking me a while to get a working test so here's the revert.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 13, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 14, 2023
…130538)

flutter/engine@0f0436b...8a42bfc

2023-07-13 skia-flutter-autoroll@skia.org Roll Skia from 52613fcc0780 to 9e4f5cc3aeb4 (1 revision) (flutter/engine#43659)
2023-07-13 jonahwilliams@google.com [Impeller] no-op fragment program on Android until it works. (flutter/engine#43657)
2023-07-13 31859944+LongCatIsLooong@users.noreply.github.com Reland #43118 "Add a flag to ParagraphBuilder for rounding hack migration" (flutter/engine#43647)
2023-07-13 ychris@google.com Unmerge threads if the current merger is the only one that's merged. (flutter/engine#43652)
2023-07-13 dnfield@google.com Revert flutter/engine#43533 (flutter/engine#43654)
2023-07-13 skia-flutter-autoroll@skia.org Roll Skia from 743ad92f5de2 to 52613fcc0780 (9 revisions) (flutter/engine#43655)

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 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
dnfield added a commit to dnfield/engine that referenced this pull request Jul 14, 2023
This reverts commit 255ef6c.
kjlubick pushed a commit to kjlubick/engine that referenced this pull request Jul 14, 2023
This patch does a few things:

- Changes ownership of the LazyGlyphAtlas to ContentContext from Canvas. This means that drawings with multiple canvases (e.g. calls to DrawPicture) share the same lazy atlas.
- Moves the scale property from Font::Metrics to FontGlyphPair. Font::Metrics contains properties related to the font, whereas scale has to do with the properties of the drawing at render time and is independent of the font.
- Makes the lazy atlas manage FontGlyphPair::Set rather than vectors of TextFrames.
- Makes the determination of font scaling at EntityPass::Render rather than Canvas::DrawTextFrame. The scaling may be altered by calls to Canvas::DrawPicture by render time and otherwise get missed. This is done via a new method: Contents::PopulateGlyphAtlas, which is only implemented by TextContents in this patch.
- Fixes up some miscelleaneous bugs in Font::Metrics hashing and unused/dead code.

This improves over prior attempts: LazyGlyphAtlas ownership is now unambiguous, and glyph scaling happens correctly for all rendered glyphs regardless of the order of canvas operations in Aiks.

Fixes flutter/flutter#130142
kjlubick pushed a commit to kjlubick/engine that referenced this pull request Jul 14, 2023
Reverts  flutter#43533
Cause of flutter/flutter#130476

I was trying to add a test for this but it's taking me a while to get a working test so here's the revert.
dnfield added a commit to dnfield/engine that referenced this pull request Jul 14, 2023
harryterkelsen pushed a commit to harryterkelsen/engine that referenced this pull request Jul 20, 2023
Reverts  flutter#43533
Cause of flutter/flutter#130476

I was trying to add a test for this but it's taking me a while to get a working test so here's the revert.
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…lutter#130538)

flutter/engine@0f0436b...8a42bfc

2023-07-13 skia-flutter-autoroll@skia.org Roll Skia from 52613fcc0780 to 9e4f5cc3aeb4 (1 revision) (flutter/engine#43659)
2023-07-13 jonahwilliams@google.com [Impeller] no-op fragment program on Android until it works. (flutter/engine#43657)
2023-07-13 31859944+LongCatIsLooong@users.noreply.github.com Reland flutter#43118 "Add a flag to ParagraphBuilder for rounding hack migration" (flutter/engine#43647)
2023-07-13 ychris@google.com Unmerge threads if the current merger is the only one that's merged. (flutter/engine#43652)
2023-07-13 dnfield@google.com Revert flutter/engine#43533 (flutter/engine#43654)
2023-07-13 skia-flutter-autoroll@skia.org Roll Skia from 743ad92f5de2 to 52613fcc0780 (9 revisions) (flutter/engine#43655)

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 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
gbtb16 pushed a commit to gbtb16/flutter that referenced this pull request Nov 6, 2023
…lutter#130313)

flutter/engine@153d9e1...767f2fb

2023-07-11 dnfield@google.com [Impeller] Improve resolution of text scaling. (flutter/engine#43533)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
No open projects
Archived in project
3 participants