forked from firka/flutter
[Impeller] Adjust clip coverage operations to handle per-pass clip stacks (flutter/engine#46912)
https://github.com/flutter/engine/pull/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.
This commit is contained in:
@@ -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<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.
|
||||
|
||||
Reference in New Issue
Block a user