-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Incorporate filters in subpass coverage. #45778
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. |
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
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 |
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.
/// @brief Returns true of this filter graph performs basis transformations | |
/// @brief Returns true if this filter graph performs basis transformations |
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.
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. |
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.
Is translating the only kind of non-basis transform? Could we rephrase this as "TranslateOnly"?
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.
Yeah, inverted this.
impeller/entity/entity_pass.cc
Outdated
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()); | ||
} |
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.
nit: this code feels complicated enough that you might want to pull it into a helper method.
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.
Done.
@@ -60,14 +60,21 @@ std::shared_ptr<Contents> Paint::WithFilters( | |||
std::shared_ptr<Contents> input) const { | |||
input = WithColorFilter(input, /*absorb_opacity=*/true); |
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.
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.
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.
Added an issue about this: flutter/flutter#134681
Golden file changes are available for triage from new commit, Click here to view. |
…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 |
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.
Should this be !IsTranslationOnly()
?
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.
Yeah
…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
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.
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:
After: