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

Commit 9f6113c

Browse files
bderoharryterkelsen
authored andcommitted
1 parent 479cd92 commit 9f6113c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

impeller/entity/entity_pass.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,43 @@ std::optional<Rect> EntityPass::GetElementsCoverage(
124124

125125
std::optional<Rect> unfiltered_coverage =
126126
GetSubpassCoverage(subpass, std::nullopt);
127+
128+
// If the current pass elements have any coverage so far and there's a
129+
// backdrop filter, then incorporate the backdrop filter in the
130+
// pre-filtered coverage of the subpass.
131+
if (result.has_value() && subpass.backdrop_filter_proc_) {
132+
std::shared_ptr<FilterContents> backdrop_filter =
133+
subpass.backdrop_filter_proc_(FilterInput::Make(result.value()),
134+
subpass.xformation_,
135+
Entity::RenderingMode::kSubpass);
136+
if (backdrop_filter) {
137+
auto backdrop_coverage = backdrop_filter->GetCoverage({});
138+
backdrop_coverage->origin += result->origin;
139+
if (backdrop_coverage.has_value()) {
140+
if (unfiltered_coverage.has_value()) {
141+
unfiltered_coverage = coverage->Union(*backdrop_coverage);
142+
} else {
143+
unfiltered_coverage = backdrop_coverage;
144+
}
145+
}
146+
} else {
147+
VALIDATION_LOG << "The EntityPass backdrop filter proc didn't return "
148+
"a valid filter.";
149+
}
150+
}
151+
127152
if (!unfiltered_coverage.has_value()) {
128153
continue;
129154
}
130155

156+
// Additionally, subpass textures may be passed through filters, which may
157+
// modify the coverage.
158+
//
159+
// Note that we currently only assume that ImageFilters (such as blurs and
160+
// matrix transforms) may modify coverage, although it's technically
161+
// possible ColorFilters to affect coverage as well. For example: A
162+
// ColorMatrixFilter could output a completely transparent result, and
163+
// we could potentially detect this case as zero coverage in the future.
131164
std::shared_ptr<FilterContents> image_filter =
132165
subpass.delegate_->WithImageFilter(*unfiltered_coverage,
133166
subpass.xformation_);

0 commit comments

Comments
 (0)