Skip to content

Commit

Permalink
[Impeller] Adjust clip coverage operations to handle per-pass clip st…
Browse files Browse the repository at this point in the history
…acks (#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.
  • Loading branch information
jason-simmons committed Oct 16, 2023
1 parent ca8cf6b commit 172ad1f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ bool EntityPass::OnRender(
ClipCoverageLayer{.coverage = clip_coverage.coverage,
.clip_depth = element_entity.GetClipDepth() + 1});
FML_DCHECK(clip_coverage_stack.back().clip_depth ==
clip_coverage_stack.size() - 1);
clip_coverage_stack.front().clip_depth +
clip_coverage_stack.size() - 1);

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

auto restoration_depth = element_entity.GetClipDepth();
FML_DCHECK(restoration_depth < clip_coverage_stack.size());
auto restoration_index = element_entity.GetClipDepth() -
clip_coverage_stack.front().clip_depth;
FML_DCHECK(restoration_index < clip_coverage_stack.size());

// We only need to restore the area that covers the coverage of the
// clip rect at target depth + 1.
std::optional<Rect> restore_coverage =
(restoration_depth + 1 < clip_coverage_stack.size())
? clip_coverage_stack[restoration_depth + 1].coverage
(restoration_index + 1 < clip_coverage_stack.size())
? clip_coverage_stack[restoration_index + 1].coverage
: std::nullopt;
if (restore_coverage.has_value()) {
// Make the coverage rectangle relative to the current pass.
restore_coverage->origin -= global_pass_position;
}
clip_coverage_stack.resize(restoration_depth + 1);
clip_coverage_stack.resize(restoration_index + 1);

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

0 comments on commit 172ad1f

Please sign in to comment.