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

Commit 172ad1f

Browse files
[Impeller] Adjust clip coverage operations to handle per-pass clip stacks (#46912)
#46597 creates a new clip coverage stack for each subpass. This PR updates some clip coverage operations and assertions in EntityPass::OnRender to reflect that the current clip coverage stack only contains the range of depths within the current subpass.
1 parent ca8cf6b commit 172ad1f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

impeller/entity/entity_pass.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ bool EntityPass::OnRender(
809809
ClipCoverageLayer{.coverage = clip_coverage.coverage,
810810
.clip_depth = element_entity.GetClipDepth() + 1});
811811
FML_DCHECK(clip_coverage_stack.back().clip_depth ==
812-
clip_coverage_stack.size() - 1);
812+
clip_coverage_stack.front().clip_depth +
813+
clip_coverage_stack.size() - 1);
813814

814815
if (!op.has_value()) {
815816
// Running this append op won't impact the clip buffer because the
@@ -824,20 +825,21 @@ bool EntityPass::OnRender(
824825
return true;
825826
}
826827

827-
auto restoration_depth = element_entity.GetClipDepth();
828-
FML_DCHECK(restoration_depth < clip_coverage_stack.size());
828+
auto restoration_index = element_entity.GetClipDepth() -
829+
clip_coverage_stack.front().clip_depth;
830+
FML_DCHECK(restoration_index < clip_coverage_stack.size());
829831

830832
// We only need to restore the area that covers the coverage of the
831833
// clip rect at target depth + 1.
832834
std::optional<Rect> restore_coverage =
833-
(restoration_depth + 1 < clip_coverage_stack.size())
834-
? clip_coverage_stack[restoration_depth + 1].coverage
835+
(restoration_index + 1 < clip_coverage_stack.size())
836+
? clip_coverage_stack[restoration_index + 1].coverage
835837
: std::nullopt;
836838
if (restore_coverage.has_value()) {
837839
// Make the coverage rectangle relative to the current pass.
838840
restore_coverage->origin -= global_pass_position;
839841
}
840-
clip_coverage_stack.resize(restoration_depth + 1);
842+
clip_coverage_stack.resize(restoration_index + 1);
841843

842844
if (!clip_coverage_stack.back().coverage.has_value()) {
843845
// Running this restore op won't make anything renderable, so skip it.

0 commit comments

Comments
 (0)