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

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Sep 28, 2023

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.

@jonahwilliams jonahwilliams marked this pull request as ready for review September 29, 2023 00:13
@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 #46391 at sha bc1dcab

Comment on lines 491 to 508
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);
}
Copy link
Contributor Author

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:

  1. Be resilient to dl dispatch order and
  2. Keep paint as a struct with no private fields.

Copy link
Member

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.

Copy link
Member

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++)

Copy link
Contributor Author

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.

@jonahwilliams
Copy link
Contributor Author

Hmm, all of these colors should be the same....

jonahwilliams added 2 commits September 28, 2023 17:38
@jonahwilliams
Copy link
Contributor Author

okay, changed the filters around...

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #46391 at sha 2ca5a11

}

TEST_P(AiksTest, CanRenderInvertedImage) {
constexpr ColorMatrix kColorInversion = {.array = {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 29, 2023
@auto-submit auto-submit bot merged commit 7326ccb into flutter:main Sep 29, 2023
if (paint_.color_filter) {
auto color_filter = ToColorFilter(filter);
paint_.color_filter =
ColorFilter::MakeComposed(paint_.color_filter, color_filter);
Copy link
Member

@bdero bdero Sep 29, 2023

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted!

@jonahwilliams jonahwilliams added the revert Label used to revert changes in a closed and merged pull request. label Sep 29, 2023
auto-submit bot pushed a commit that referenced this pull request Sep 29, 2023
@auto-submit auto-submit bot removed the revert Label used to revert changes in a closed and merged pull request. label Sep 29, 2023
auto-submit bot added a commit that referenced this pull request Sep 29, 2023
…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.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 29, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 29, 2023
…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
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…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
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
…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.
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
…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.
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] setting paint.invertColors does not work if you also set a colorFilter on the paint.

3 participants