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

[Impeller] Incorporate filters in subpass coverage. #45778

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

bdero
Copy link
Member

@bdero bdero commented Sep 13, 2023

Resolves flutter/flutter#131182.

I adjusted the size of the matrix filtered circle in both SaveLayer Matrix filter test variants (post-filter and backdrop filter) to move the transformed circle outside the coverage area that would be computed if subpass filters aren't being accounted for. Further, we need to avoid intersecting with the pass coverage hint when the transformation being applied by the paint's filter graph causes the Entity's space basis to deviate from the parent pass basis. We're still able to apply it for simple translations, though.

Before:

Screenshot 2023-09-13 at 10 46 13 AM

After:

Screenshot 2023-09-13 at 10 48 38 AM

@bdero bdero self-assigned this Sep 13, 2023
@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 #45778 at sha 1a09663

Copy link
Contributor

@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

virtual Matrix GetLocalTransform(const Matrix& parent_transform) const;

Matrix GetTransform(const Matrix& parent_transform) const;

/// @brief Returns true of this filter graph performs basis transformations
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @brief Returns true of this filter graph performs basis transformations
/// @brief Returns true if this filter graph performs basis transformations

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

virtual Matrix GetLocalTransform(const Matrix& parent_transform) const;

Matrix GetTransform(const Matrix& parent_transform) const;

/// @brief Returns true of this filter graph performs basis transformations
/// to the filtered content. For example: Rotating, scaling, and
/// skewing are all basis transformations, but translating is not.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is translating the only kind of non-basis transform? Could we rephrase this as "TranslateOnly"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, inverted this.

Comment on lines 115 to 145
if (coverage.has_value() && coverage_limit.has_value()) {
coverage = coverage->Intersection(coverage_limit.value());
const auto* filter = entity->GetContents()->AsFilter();
if (!filter || !filter->HasBasisTransformations()) {
coverage = coverage->Intersection(coverage_limit.value());
}
}
} else if (auto subpass =
} else if (auto subpass_ptr =
std::get_if<std::unique_ptr<EntityPass>>(&element)) {
coverage = GetSubpassCoverage(*subpass->get(), coverage_limit);
auto& subpass = *subpass_ptr->get();

std::optional<Rect> unfiltered_coverage =
GetSubpassCoverage(subpass, std::nullopt);
if (!unfiltered_coverage.has_value()) {
continue;
}

std::shared_ptr<FilterContents> image_filter =
subpass.delegate_->WithImageFilter(*unfiltered_coverage,
subpass.xformation_);
if (image_filter) {
Entity subpass_entity;
subpass_entity.SetTransformation(subpass.xformation_);
coverage = image_filter->GetCoverage(subpass_entity);
} else {
coverage = unfiltered_coverage;
}

if (coverage.has_value() && coverage_limit.has_value() &&
(!image_filter || !image_filter->HasBasisTransformations())) {
coverage = coverage->Intersection(coverage_limit.value());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this code feels complicated enough that you might want to pull it into a helper method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -60,14 +60,21 @@ std::shared_ptr<Contents> Paint::WithFilters(
std::shared_ptr<Contents> input) const {
input = WithColorFilter(input, /*absorb_opacity=*/true);
Copy link
Member

Choose a reason for hiding this comment

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

Dry by comment on an unrelated item: Instead of booleans for absorb_opacity and is_subpass, I'd rather have a typed enum with AbsorbOpacity::kYes and AbsorbOpacity::kNo and the like.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added an issue about this: flutter/flutter#134681

@flutter-dashboard
Copy link

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

Changes reported for pull request #45778 at sha 61d3746

@bdero bdero merged commit c39eb69 into flutter:main Sep 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 14, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 14, 2023
…134755)

flutter/engine@2cd34d2...e0b5b6c

2023-09-14 [email protected] Roll Skia from 54253f58533d to 87025d1e162c (1 revision) (flutter/engine#45833)
2023-09-14 [email protected] [Impeller] Incorporate filters in subpass coverage. (flutter/engine#45778)

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
// has deviated too much from the parent pass to safely intersect with the
// pass coverage limit.
coverage_limit =
(image_filter && image_filter->IsTranslationOnly() ? std::nullopt
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be !IsTranslationOnly()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah

Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…lutter#134755)

flutter/engine@2cd34d2...e0b5b6c

2023-09-14 [email protected] Roll Skia from 54253f58533d to 87025d1e162c (1 revision) (flutter/engine#45833)
2023-09-14 [email protected] [Impeller] Incorporate filters in subpass coverage. (flutter/engine#45778)

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
I adjusted the size of the matrix filtered circle in both SaveLayer
Matrix filter test variants (post-filter and backdrop filter) to move
the transformed circle outside the coverage area that would be computed
if subpass filters aren't being accounted for. Further, we need to avoid
intersecting with the pass coverage hint when the transformation being
applied by the paint's filter graph causes the Entity's space basis to
deviate from the parent pass basis. We're still able to apply it for
simple translations, though.
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] Stack + Positioned + Transform with FilterQuality clips the widget.
4 participants