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

[Impeller] Fix MatrixFilter multiplication ordering for subpasses. #43943

Merged
merged 2 commits into from
Jul 24, 2023

Conversation

bdero
Copy link
Member

@bdero bdero commented Jul 24, 2023

Resolves flutter/flutter#130355.

When drawing a backdrop filter, we offset the backdrop entity with -local_pass_position in order to align the backdrop texture with the position of the pass it's being drawn to. When rendering the filter, this transform propagates to the filter snapshot. Prior to this change, that offset was being applied within the space of the backdrop filter's matrix, which is wrong! It needs to be applied in screen space.

We didn't notice this prior to the coverage hint optimization because we were previously forcing subpass sizes to match the parent whenever a backdrop filter was present.

This one was very difficult to reason through at first, and so I added a detailed comment to explain the rationale behind the behavioral differences between the backdrop filter and non-backdrop filter cases of the matrix filter.

I also updated the golden to more clearly show the coverage leak I was getting at when I filed flutter/flutter#130355. It's not causing known issues with real widgets, however, and so I'm going to set it to the side for now.

Before:

before.mp4

After:

after.mp4

@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 #43943 at sha 183e3e4

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

We should consider cherry picking this into 3.13, if you feel confident in it.

@bdero bdero merged commit 33a24ff into flutter:main Jul 24, 2023
bdero added a commit that referenced this pull request Jul 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 24, 2023
auto-submit bot pushed a commit that referenced this pull request Jul 24, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 25, 2023
…131225)

flutter/engine@ff02fa7...4fded78

2023-07-24 skia-flutter-autoroll@skia.org Roll Skia from 6c219acc30a5 to 4554d1b35b6e (4 revisions) (flutter/engine#43973)
2023-07-24 bdero@google.com [Impeller] Fix MatrixFilter multiplication ordering for subpasses. (flutter/engine#43943)

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 bdero@google.com,rmistry@google.com,zra@google.com 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
bdero added a commit that referenced this pull request Jul 25, 2023
Follow-up/reland of #43943.

Issue flutter/flutter#130355.

I've updated the golden to better reproduce the problem at hand; the
second circle is a scaled down copy of the backdrop. If the matrix
filter is handling the transform correctly, the circle is centered over
the bottom-right-most edge (4:30) of the circle:

![image](https://github.com/flutter/engine/assets/919017/3f2e099d-9d43-4ee6-8efe-3203edad47ad)
bdero added a commit to bdero/flutter-engine that referenced this pull request Jul 25, 2023
)

Follow-up/reland of flutter#43943.

Issue flutter/flutter#130355.

I've updated the golden to better reproduce the problem at hand; the
second circle is a scaled down copy of the backdrop. If the matrix
filter is handling the transform correctly, the circle is centered over
the bottom-right-most edge (4:30) of the circle:

![image](https://github.com/flutter/engine/assets/919017/3f2e099d-9d43-4ee6-8efe-3203edad47ad)

(cherry picked from commit 3e5ae6a)
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…lutter#131225)

flutter/engine@ff02fa7...4fded78

2023-07-24 skia-flutter-autoroll@skia.org Roll Skia from 6c219acc30a5 to 4554d1b35b6e (4 revisions) (flutter/engine#43973)
2023-07-24 bdero@google.com [Impeller] Fix MatrixFilter multiplication ordering for subpasses. (flutter/engine#43943)

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 bdero@google.com,rmistry@google.com,zra@google.com 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
vashworth pushed a commit to vashworth/flutter that referenced this pull request Aug 2, 2023
…lutter#131225)

flutter/engine@ff02fa7...4fded78

2023-07-24 skia-flutter-autoroll@skia.org Roll Skia from 6c219acc30a5 to 4554d1b35b6e (4 revisions) (flutter/engine#43973)
2023-07-24 bdero@google.com [Impeller] Fix MatrixFilter multiplication ordering for subpasses. (flutter/engine#43943)

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 bdero@google.com,rmistry@google.com,zra@google.com 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
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
)

Follow-up/reland of flutter#43943.

Issue flutter/flutter#130355.

I've updated the golden to better reproduce the problem at hand; the
second circle is a scaled down copy of the backdrop. If the matrix
filter is handling the transform correctly, the circle is centered over
the bottom-right-most edge (4:30) of the circle:

![image](https://github.com/flutter/engine/assets/919017/3f2e099d-9d43-4ee6-8efe-3203edad47ad)
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request May 16, 2024
…lutter#43943)

Resolves flutter/flutter#130355.

When drawing a backdrop filter, we offset the backdrop entity with
`-local_pass_position` in order to align the backdrop texture with the
position of the pass it's being drawn to. When rendering the filter,
this transform propagates to the filter snapshot. Prior to this change,
that offset was being applied within the space of the backdrop filter's
matrix, which is wrong! It needs to be applied in screen space.

We didn't notice this prior to the coverage hint optimization because we
were previously forcing subpass sizes to match the parent whenever a
backdrop filter was present.

This one was very difficult to reason through at first, and so I added a
detailed comment to explain the rationale behind the behavioral
differences between the backdrop filter and non-backdrop filter cases of
the matrix filter.
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request May 16, 2024
…lutter#43943)

Resolves flutter/flutter#130355.

When drawing a backdrop filter, we offset the backdrop entity with
`-local_pass_position` in order to align the backdrop texture with the
position of the pass it's being drawn to. When rendering the filter,
this transform propagates to the filter snapshot. Prior to this change,
that offset was being applied within the space of the backdrop filter's
matrix, which is wrong! It needs to be applied in screen space.

We didn't notice this prior to the coverage hint optimization because we
were previously forcing subpass sizes to match the parent whenever a
backdrop filter was present.

This one was very difficult to reason through at first, and so I added a
detailed comment to explain the rationale behind the behavioral
differences between the backdrop filter and non-backdrop filter cases of
the matrix filter.
auto-submit bot pushed a commit that referenced this pull request May 18, 2024
fixes: flutter/flutter#147807
relands #43943 (with fixes that hopefully avoid it being reverted again)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot added a commit that referenced this pull request May 18, 2024
)

Reverts: #52880
Initiated by: jonahwilliams
Reason for reverting: unexpected framework golden change
Original PR Author: gaaclarke

Reviewed By: {bdero}

This change reverts the following previous change:
fixes: flutter/flutter#147807
relands #43943 (with fixes that hopefully avoid it being reverted again)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
gaaclarke added a commit to gaaclarke/engine that referenced this pull request May 20, 2024
fixes: flutter/flutter#147807
relands flutter#43943 (with fixes that hopefully avoid it being reverted again)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request May 21, 2024
fixes flutter/flutter#147807
relands #52880
relands #43943

This was previously reverted because of the golden test failure `widgets.widgets.magnifier.styled`.  This fixes that problem by instead of focusing on ImageFilter and BackdropFilter subpasses, instead focuses on wether a subpass is clipped or not and by extension how the math should be handled.

`widgets.widgets.magnifier.styled` after diff:

![widgets widgets magnifier styled](https://github.com/flutter/engine/assets/30870216/d4611586-90f7-4d3e-90d8-018dd678d028)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Impeller] Android text magnifier not offsetting correctly with coverage hint optimization.
2 participants