-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] simplify invert colors flag by supporting composed color filters. #46391
[Impeller] simplify invert colors flag by supporting composed color filters. #46391
Conversation
|
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. |
| if (paint_.color_filter) { | ||
| auto color_filter = ToColorFilter(filter); | ||
| paint_.color_filter = std::make_shared<MergedColorFilter>( | ||
| std::move(paint_.color_filter), color_filter); | ||
| } else { | ||
| paint_.color_filter = ToColorFilter(filter); | ||
| } | ||
| } | ||
|
|
||
| // |flutter::DlOpReceiver| | ||
| void DlDispatcher::setInvertColors(bool invert) { | ||
| paint_.invert_colors = invert; | ||
| if (paint_.color_filter) { | ||
| auto invert_filter = ColorFilter::MakeMatrix(kColorInversion); | ||
| paint_.color_filter = std::make_shared<MergedColorFilter>( | ||
| invert_filter, std::move(paint_.color_filter)); | ||
| } else { | ||
| paint_.color_filter = ColorFilter::MakeMatrix(kColorInversion); | ||
| } |
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 sucks but there is no good answer to:
- Be resilient to dl dispatch order and
- Keep paint as a struct with no private fields.
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.
To solve the composing problem, one possibility would be to add a "GetInverted()" to ColorFilter that returns a new composed filter with the color filter inversion appended.
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 one of those cases where I would clone things liberally to prevent bugs -- the only reason these things are smart pointers is for dynamic dispatch, but like so many things in Impeller, these should really just be discriminated unions, but we currently have an aversion for those in C++)
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.
Right, this is 2.5 which is "callers need to be aware of both fields" which I guess is just us, but not idea.
|
Hmm, all of these colors should be the same.... |
|
okay, changed the filters around... |
|
Golden file changes are available for triage from new commit, Click here to view. |
| } | ||
|
|
||
| TEST_P(AiksTest, CanRenderInvertedImage) { | ||
| constexpr ColorMatrix kColorInversion = {.array = { |
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 now defined in at least three places - it'd be nice if it could live in some common header somewhere.
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.
We could pull this logic all the way up too painting.dart but then we wont be able to test it with impeller yet. For the purposes of this test though it doesn't really matter what the filter is, just that it composes.
dnfield
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 with nit
| if (paint_.color_filter) { | ||
| auto color_filter = ToColorFilter(filter); | ||
| paint_.color_filter = | ||
| ColorFilter::MakeComposed(paint_.color_filter, color_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.
Does the paint state get cleared out between every draw call? I think this solution implicitly relies on setColorFilter and setInvertColors always being called exactly once per dispatch.
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.
ugh yeah
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 hate 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.
reverted!
…d color filters." (#46414) Reverts #46391 Initiated by: jonahwilliams This change reverts the following previous change: Original Description: Fixes flutter/flutter#135699 To avoid the ugly complicated code for conditionally applying both colorfilters, make the dl dispatcher handle merging these filters together in a defined order. The original bug is caused by not checking for invert colors in a CPU fast path.
…135765) flutter/engine@d5fcd78...48973d7 2023-09-29 [email protected] Manual roll Dart SDK from e042e83c85a5 to 955a3a964621 (2 revisions) (flutter/engine#46412) 2023-09-29 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] simplify invert colors flag by supporting composed color filters." (flutter/engine#46414) 2023-09-29 [email protected] [Impeller] simplify invert colors flag by supporting composed color filters. (flutter/engine#46391) 2023-09-29 [email protected] Manual roll Dart SDK from 077d768accfa to e042e83c85a5 (3 revisions) (flutter/engine#46409) 2023-09-29 [email protected] Roll Skia from 9f8242377455 to 2d4045f55fd5 (3 revisions) (flutter/engine#46408) 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
…lutter#135765) flutter/engine@d5fcd78...48973d7 2023-09-29 [email protected] Manual roll Dart SDK from e042e83c85a5 to 955a3a964621 (2 revisions) (flutter/engine#46412) 2023-09-29 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] simplify invert colors flag by supporting composed color filters." (flutter/engine#46414) 2023-09-29 [email protected] [Impeller] simplify invert colors flag by supporting composed color filters. (flutter/engine#46391) 2023-09-29 [email protected] Manual roll Dart SDK from 077d768accfa to e042e83c85a5 (3 revisions) (flutter/engine#46409) 2023-09-29 [email protected] Roll Skia from 9f8242377455 to 2d4045f55fd5 (3 revisions) (flutter/engine#46408) 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
…ilters. (#46391) Fixes flutter/flutter#135699 To avoid the ugly complicated code for conditionally applying both colorfilters, make the dl dispatcher handle merging these filters together in a defined order. The original bug is caused by not checking for invert colors in a CPU fast path.
…d color filters." (#46414) Reverts #46391 Initiated by: jonahwilliams This change reverts the following previous change: Original Description: Fixes flutter/flutter#135699 To avoid the ugly complicated code for conditionally applying both colorfilters, make the dl dispatcher handle merging these filters together in a defined order. The original bug is caused by not checking for invert colors in a CPU fast path.
Fixes flutter/flutter#135699
To avoid the ugly complicated code for conditionally applying both colorfilters, make the dl dispatcher handle merging these filters together in a defined order. The original bug is caused by not checking for invert colors in a CPU fast path.