Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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