Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

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

dnfield added 2 commits July 10, 2023 15:08
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
Contributor

@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


// ---------------------------------------------------------------------------
// 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] Using Canvas::DrawPicture with text renders text at the wrong scale.

3 participants