Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,29 @@ TEST_P(AiksTest, CanRenderDifferenceClips) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderWithContiguousClipRestores) {
Canvas canvas;

// Cover the whole canvas with red.
canvas.DrawPaint({.color = Color::Red()});

canvas.Save();

// Append two clips. First with empty coverage.
canvas.ClipPath(
PathBuilder{}.AddRect(Rect::MakeXYWH(100, 100, 100, 100)).TakePath());
canvas.ClipPath(
PathBuilder{}.AddRect(Rect::MakeXYWH(100, 100, 100, 100)).TakePath());

// Restore to no clips.
canvas.Restore();

// Replace the whole canvas with green.
canvas.DrawPaint({.color = Color::Green()});

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, ClipsUseCurrentTransform) {
std::array<Color, 5> colors = {Color::White(), Color::Black(),
Color::SkyBlue(), Color::Red(),
Expand Down
9 changes: 6 additions & 3 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,14 @@ bool EntityPass::OnRender(
return true;
}

FML_DCHECK(stencil_stack.size() > 1);
auto restoration_depth =
element_entity.GetStencilDepth() - stencil_depth_floor;
FML_DCHECK(restoration_depth < stencil_stack.size());

stencil_stack.pop_back();
auto restored_coverage = stencil_stack.back().coverage;
stencil_stack.resize(restoration_depth + 1);

if (!stencil_stack.back().coverage.has_value()) {
if (!restored_coverage.has_value()) {
// Running this restore op won't make anything renderable, so skip it.
return true;
}
Expand Down