diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index 11219ad4937d5..4d6897b5b3445 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -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 @@ -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 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.