-
Notifications
You must be signed in to change notification settings - Fork 6k
[DisplayList] migrate DlImageFilter code to Impeller geometry classes #56720
[DisplayList] migrate DlImageFilter code to Impeller geometry classes #56720
Conversation
981ba0f to
199970f
Compare
|
There are just a few lines of code in dl_image_filter.cc that still use the Skia classes for bounds computation as they seem to pass the perspective transform tests better, but otherwise the ImageFilter code is 99.5% migrated to the Impeller classes including what should be 100% of the API (not including the use of SkShader by the runtime effect class). See flutter/flutter#159175 for more information. |
|
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. |
|
I find the golden diffs interesting. They are very tiny, but they don't appear (by name) to involve image filters. |
gaaclarke
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.
Woo, that was a lot to look at. Mostly looking good, here's some notes and questions.
| // A backdrop will affect up to the entire surface, bounded by the clip | ||
| bool will_be_unbounded = (backdrop != nullptr); | ||
| std::shared_ptr<const DlImageFilter> filter; | ||
| std::shared_ptr<DlImageFilter> filter; |
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 change this?
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.
The classes are immutable and I was having trouble with the fact that you can't mix and match shared_ptr with different "const" modifiers.
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.
https://google.github.io/styleguide/cppguide.html#Use_of_const
Immutable classes should have const methods so having a const reference should still be the appropriate usage in c++.
display_list/dl_builder.cc
Outdated
| if (global_bounds.intersect(clip)) { | ||
| parent_layer().global_space_accumulator.accumulate(global_bounds); | ||
| global_bounds = DlRect::Make(global_ibounds); | ||
| auto clipped_bounds = global_bounds.Intersection(clip); |
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.
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
|
|
||
| // |DlCanvas| | ||
| void SaveLayer(std::optional<const DlRect>& bounds, | ||
| void SaveLayer(const std::optional<DlRect>& bounds, |
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 was this changed?
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.
const in an optional doesn't really prevent you from changing it, the optional itself has to be const. And at that point, why have the const inside the template type?
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 have the const inside the template type?
To make sure no one modifies the DlRect. I would have expected const std::optional<const DlRect>& bounds
| namespace flutter { | ||
|
|
||
| ImageFilterLayer::ImageFilterLayer(std::shared_ptr<const DlImageFilter> filter, | ||
| ImageFilterLayer::ImageFilterLayer(const std::shared_ptr<DlImageFilter>& filter, |
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 don't think switching these to const references is an improvement. With the std::move there ways to avoid a copy, the const reference forces a copy to happen.
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.
These are always called from a reference source that cannot be moved so a copy must happen at some point. It would be better if the copy happened into the layer's local field rather than to the value handed in to the constructor.
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.
You are considering just the code that is written today. There is no way to enforce that this is only called with references.
| // The transform from the local coordinates to the device coordinates | ||
| // in 4x4 DlMatrix representation. This matrix provides all information | ||
| // needed to compute bounds for a 2D rendering primitive, and it will | ||
| // accurately concatenate with other 4x4 matrices without losing information. |
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.
Please write as a docstring (ie ///)
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.
None of the methods in this file are docstring. This is an issue with a scope outside of this change - flutter/flutter#159179
| return TRect(0.0, 0.0, size.width, size.height); | ||
| } | ||
|
|
||
| template <class U, class FT = T> |
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.
docstring would help here, it's not immediately clear to me what this is for. it's copying a rect, but why the enable_if_t? If this potentially throwing away precision implicitly?
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. It's only defined for float destinations. If you want to convert to an integer rect you have to use a method like RoundOut to specify the rounding behavior.
|
|
||
| Scalar GetDeterminant() const; | ||
|
|
||
| bool IsInvertible() const { return GetDeterminant() != 0; } |
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 put these in the implementation?
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'm not sure what you are asking?
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 forget the proper terminology :). Can you put the method bodies in the .cc file?
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.
These geometry files seem to prefer inline implementations unless the method is very complicated.
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.
flutter/flutter#159220 - we should reconsider the decisions made in that module separately.
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!
…159226) flutter/engine@3828681...2d32cf3 2024-11-20 [email protected] [DisplayList] migrate DlImageFilter code to Impeller geometry classes (flutter/engine#56720) 2024-11-20 [email protected] Split channel messaging out of handlers (flutter/engine#56667) 2024-11-20 [email protected] Revert "Added assert for opengles thread safety (#56585)" (flutter/engine#56730) 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
…flutter/engine#56720) The DlImageFilter code uses Skia geometry classes for its internal computations. This PR switches those implementations to use the Impeller geometry classes for consistency and 3rd party header file independence.
The DlImageFilter code uses Skia geometry classes for its internal computations. This PR switches those implementations to use the Impeller geometry classes for consistency and 3rd party header file independence.