[Impeller] Check coverage after screen clip (flutter/engine#41129)

[Impeller] Check coverage after screen clip
This commit is contained in:
Brandon DeRosier 2023-04-12 16:21:48 -07:00 committed by GitHub
parent 56821f80e7
commit 7eef190afb
2 changed files with 26 additions and 1 deletions

View File

@ -2099,5 +2099,25 @@ TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixImageFilterDrawsCorrectly) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
/// This is a regression check for https://github.com/flutter/engine/pull/41129
/// The entire screen is green if successful. If failing, no frames will render,
/// or the entire screen will be transparent black.
TEST_P(AiksTest, CanRenderTinyOverlappingSubpasses) {
Canvas canvas;
canvas.DrawPaint({.color = Color::Red()});
// Draw two overlapping subpixel circles.
canvas.SaveLayer({});
canvas.DrawCircle({100, 100}, 0.1, {.color = Color::Yellow()});
canvas.Restore();
canvas.SaveLayer({});
canvas.DrawCircle({100, 100}, 0.1, {.color = Color::Yellow()});
canvas.Restore();
canvas.DrawPaint({.color = Color::Green()});
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
} // namespace testing
} // namespace impeller

View File

@ -397,13 +397,18 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
}
}
if (!subpass_coverage.has_value() || subpass_coverage->size.IsEmpty()) {
if (!subpass_coverage.has_value()) {
// The subpass doesn't contain anything visible, so skip it.
return EntityPass::EntityResult::Skip();
}
subpass_coverage =
subpass_coverage->Intersection(Rect::MakeSize(root_pass_size));
if (!subpass_coverage.has_value() ||
ISize(subpass_coverage->size).IsEmpty()) {
// The subpass doesn't contain anything visible, so skip it.
return EntityPass::EntityResult::Skip();
}
auto subpass_target =
CreateRenderTarget(renderer, //