-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes MatrixFilterContents rendering/coverage #52880
Conversation
…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.
@@ -28,6 +28,17 @@ void MatrixFilterContents::SetSamplerDescriptor(SamplerDescriptor desc) { | |||
sampler_descriptor_ = std::move(desc); | |||
} | |||
|
|||
namespace { | |||
Matrix CalculateSubpassTransform(const Matrix& entity_transform, |
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.
@bdero this is what I was talking about the other day. We should be sharing the math between rendering and coverage.
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! Thanks for looking through this.
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. |
Golden file changes are available for triage from new commit, Click here to view. |
Golden file changes are available for triage from new commit, Click here to view. |
This passes all tests, but @bdero and I are auditing it to make sure it's correct. So don't land this yet. |
I think the check for translation hack works because it is by proxy detecting the Canvas::Save flow as opposed to the ImageFilter flow. In the Canvas::Save path the effect_transform is truncated to its basis before it is passed down ( engine/impeller/entity/entity_pass.cc Line 590 in 4e33c10
|
@bdero I made that change we discussed, can you please take a look. We decided offline that we are clearly seeing 3 different cases that need to be handled at the MatrixImageFilterContents level. So we expanded the RenderMode to reflect those 3 cases. I suspect maybe we are misusing the effect transform where we get it meaning 3 different things in 3 different contexts. Hopefully we can clear that up in the future. |
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, thanks!
This looks like its working incorrectly with some magnifier goldens in the framework: Top is the Impeller golden diff and bottom is current Skia (which is unchanged) |
reason for revert: unexpected framework golden change |
This reverts commit 2f80d28.
) 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
…148595) flutter/engine@93f1b5a...552a965 2024-05-18 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fixes MatrixFilterContents rendering/coverage (#52880)" (flutter/engine#52918) 2024-05-18 30870216+gaaclarke@users.noreply.github.com Fixes MatrixFilterContents rendering/coverage (flutter/engine#52880) 2024-05-17 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[macOS] Generate universal gen_snapshots (#52885)" (flutter/engine#52913) 2024-05-17 chris@bracken.jp [macOS] Generate universal gen_snapshots (flutter/engine#52885) 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://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
Here are the matrices for the magnifier.styled test:
It's going through the
diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc
index ee28a0dd4f..1cc997d5cc 100644
--- a/impeller/entity/entity_pass.cc
+++ b/impeller/entity/entity_pass.cc
@@ -585,9 +586,10 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
auto texture = pass_context.GetTexture();
// Render the backdrop texture before any of the pass elements.
const auto& proc = subpass->backdrop_filter_proc_;
subpass_backdrop_filter_contents = proc(
FilterInput::Make(std::move(texture)), subpass->transform_.Basis(),
- Entity::RenderingMode::kBackdropSubpass);
+ Entity::RenderingMode::kImageFilterSubpass);
Edit: I was mistaken, that leaves us in the same state as before we landed this (everything works but |
As an experiment I tried to remove the |
This patch seems to make the engine and framework tests happy. I'm not familiar with ContentBoundsPromise but it roughly sounds like it could effect the contents we get from the snapshot and determines how we should be performing the math: diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc
index 984403629c..13e99b3ced 100644
--- a/impeller/entity/entity_pass.cc
+++ b/impeller/entity/entity_pass.cc
@@ -585,9 +585,17 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
auto texture = pass_context.GetTexture();
// Render the backdrop texture before any of the pass elements.
const auto& proc = subpass->backdrop_filter_proc_;
subpass_backdrop_filter_contents = proc(
FilterInput::Make(std::move(texture)), subpass->transform_.Basis(),
- Entity::RenderingMode::kImageFilterSubpass);
+ subpass->bounds_promise_ == ContentBoundsPromise::kContainsContents ?
+ Entity::RenderingMode::kImageFilterSubpass :
+ Entity::RenderingMode::kBackdropSubpass);
// If the very first thing we render in this EntityPass is a subpass that
// happens to have a backdrop filter, than that backdrop filter will end If this is the correct latch we can rename the render modes accordingly. |
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
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
fixes: flutter/flutter#147807
relands #43943 (with fixes that hopefully avoid it being reverted again)
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.