-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Tiny optimizations for text rendering (avoiding extra ops and copies). #44822
Conversation
| for (const Point& point : unit_points) { | ||
| vtx.unit_position = point; | ||
| ::memcpy(contents + vertex_offset, &vtx, | ||
| sizeof(VS::PerVertexData)); | ||
| vertex_offset += sizeof(VS::PerVertexData); | ||
| ::memcpy(vtx_contents++, &vtx, sizeof(VS::PerVertexData)); | ||
| } |
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 removes vertex_count add operations.
| continue; | ||
| } | ||
| auto atlas_glyph_bounds = maybe_atlas_glyph_bounds.value(); | ||
| const Rect& atlas_glyph_bounds = maybe_atlas_glyph_bounds.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.
This removes a copy.
|
@dnfield sorry, I meant to put this into review after CI passed and I lost track of this. It's ready now. |
3f3d893 to
65990bb
Compare
| void TextContents::SetTextFrame(TextFrame&& frame) { | ||
| frame_ = std::move(frame); |
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.
Why is this better? How is the compiler not just doing this for us? haha
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.
It can't do it the way it was previously written since it can't know that the frame isn't used after frame_ is set. That's what rvalues and std::move can provide.
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.
If you look in the PR, there is one example where you can see SetTextFrame couldn't move the parameter since it is modified and then send to a different SetTextFrame. So by making it an rvalue the compiler knows its safe to just move it.
| for (const TextRun& run : frame_.GetRuns()) { | ||
| const Font& font = run.GetFont(); | ||
| auto rounded_scale = TextFrame::RoundScaledFontSize( | ||
| Scalar rounded_scale = TextFrame::RoundScaledFontSize( |
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.
Is this actually doing anything or just a style preference?
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.
It's the C++ style guide: https://google.github.io/styleguide/cppguide.html#Type_deduction
Use type deduction only if it makes the code clearer to readers who aren't familiar with the project, or if it makes the code safer. Do not use it merely to avoid the inconvenience of writing an explicit type.
…extra ops and copies). (flutter/engine#44822)
…133072) flutter/engine@0907548...21437d3 2023-08-22 [email protected] [Impeller] Tiny optimizations for text rendering (avoiding extra ops and copies). (flutter/engine#44822) 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
…and copies). (flutter#44822) …and copies) While investigating flutter/flutter#131620 I tried many things to squeeze the logic to make text batching faster. It didn't pan out but here are a handful of tweaks that make a tiny difference that I don't want to lose. ## 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] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [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/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
…and copies)
While investigating flutter/flutter#131620 I tried many things to squeeze the logic to make text batching faster. It didn't pan out but here are a handful of tweaks that make a tiny difference that I don't want to lose.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.