-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] remove heap allocation of most geometry objects. #55677
Conversation
| AddRenderEntityToCurrentPass(entity, false); | ||
| } | ||
|
|
||
| void Canvas::AddRenderEntityWithFiltersToCurrentPass(Entity& entity, |
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 CreateContentsForGeometryWithFilters but as an instance method. It immediately renders the entity at the end, which guarantees its safe to provide with a stack allocated geometry object.
|
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. |
chinmaygarde
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.
Mostly just nits. lgtm
| CoverGeometry& operator=(const CoverGeometry&) = delete; | ||
| }; | ||
|
|
||
| static_assert(std::is_trivially_destructible<CoverGeometry>::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.
A bit of a weird assertion to have in the first place TBH. Do we know why this was important? And presumably isn't now?
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 added this when we were prototyping doing a placement new allocator, but that is made obsolete by the DisplayList alignment
| FML_DCHECK(radius >= 0); | ||
| } | ||
|
|
||
| CircleGeometry::~CircleGeometry() {} |
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.
Nit: Default.
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.
Done
impeller/display_list/canvas.cc
Outdated
|
|
||
| entity.SetContents(std::move(contents_copy)); | ||
| AddRenderEntityToCurrentPass(entity, reuse_depth); | ||
| return; |
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.
Nit: Unnecessary return.
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.
Done
| return; | ||
| } | ||
|
|
||
| std::shared_ptr<Contents> contents_copy = std::move(contents); |
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.
Maybe I'm missing something obvious but I can't tell why this var was copied.
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.
contents is std::shared_ptr, but this gets assigned to so its std::shared_ptr. Same reason as the original code did this.
impeller/display_list/canvas.cc
Outdated
| } | ||
| if (paint.invert_colors) { | ||
| contents_copy = | ||
| WrapWithInvertColors(FilterInput::Make(contents_copy), |
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.
Can you move in the pointer here 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.
Done
| RoundRectGeometry::RoundRectGeometry(const Rect& bounds, const Size& radii) | ||
| : bounds_(bounds), radii_(radii) {} | ||
|
|
||
| RoundRectGeometry::~RoundRectGeometry() {} |
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.
Nit: default
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.
Done
|
|
||
| RectGeometry::RectGeometry(Rect rect) : rect_(rect) {} | ||
|
|
||
| RectGeometry::~RectGeometry() {} |
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.
Nit: default
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.
Done
| bool round) | ||
| : points_(std::move(points)), radius_(radius), round_(round) {} | ||
|
|
||
| PointFieldGeometry::~PointFieldGeometry() {} |
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.
Nit: default
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.
Done
| FML_DCHECK(width >= 0); | ||
| } | ||
|
|
||
| LineGeometry::~LineGeometry() {} |
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.
Nit: default.
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.
Done
| const Vector2 sigma_ = Vector2(0.0, 0.0); | ||
| const Entity::TileMode tile_mode_; | ||
| const BlurStyle mask_blur_style_; | ||
| std::shared_ptr<Geometry> mask_geometry_; |
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 eschewed by the C++ style guide: https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers
Who is the owner of this Geometry?
…156433) flutter/engine@167a42e...ea4a00f 2024-10-08 [email protected] [Impeller] remove heap allocation of most geometry objects. (flutter/engine#55677) 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] 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…engine#55677) Almost all geometry objects can now be stack allocated while rendering, instead of heap allocated - due to the removal of the EntityPass compositor. Clip geometries must still be heap allocated as the geometry objects are not yet stored in the display list, and the clips must be recorded for backdrop filter clip replay. The canvas stores unique_ptrs to these geometries in a vector that it clears at the end of the frame. The Geometry factory methods were adjusted to return unique ptrs, and the Geometry class given a virtual dtor since we no longer rely on the special property of std::shared_ptr for memorizing the right dtor. The ColorSourceContents and ClipContents class now hold onto a const ptr to the geometry object. At some point in the future, we can rework the geometry object to be stored inline in the display list which will further simplify this code. Part of flutter#142054
Almost all geometry objects can now be stack allocated while rendering, instead of heap allocated - due to the removal of the EntityPass compositor. Clip geometries must still be heap allocated as the geometry objects are not yet stored in the display list, and the clips must be recorded for backdrop filter clip replay.
The canvas stores unique_ptrs to these geometries in a vector that it clears at the end of the frame. The Geometry factory methods were adjusted to return unique ptrs, and the Geometry class given a virtual dtor since we no longer rely on the special property of std::shared_ptr for memorizing the right dtor.
The ColorSourceContents and ClipContents class now hold onto a const ptr to the geometry object.
At some point in the future, we can rework the geometry object to be stored inline in the display list which will further simplify this code.
Part of flutter/flutter#142054