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
25 changes: 24 additions & 1 deletion impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2134,9 +2134,12 @@ TEST_P(AiksTest, CanRenderClippedLayers) {
canvas.DrawRect(Rect::MakeSize(Size{400, 400}), {.color = Color::White()});
// Fill the layer with green, but do so with a color blend that can't be
// collapsed into the parent pass.
// TODO(jonahwilliams): this blend mode was changed from color burn to
// hardlight to work around https://github.com/flutter/flutter/issues/136554
// .
canvas.DrawRect(
Rect::MakeSize(Size{400, 400}),
{.color = Color::Green(), .blend_mode = BlendMode::kColorBurn});
{.color = Color::Green(), .blend_mode = BlendMode::kHardLight});
}

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
Expand Down Expand Up @@ -3664,5 +3667,25 @@ TEST_P(AiksTest,
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

// This should be solid red, if you see a little red box this is broken.
TEST_P(AiksTest, ClearColorOptimizationWhenSubpassIsBiggerThanParentPass) {
SetWindowSize({400, 400});
Canvas canvas;
canvas.Scale(GetContentScale());
canvas.DrawRect(Rect::MakeLTRB(200, 200, 300, 300), {.color = Color::Red()});
canvas.SaveLayer({
.image_filter = std::make_shared<MatrixImageFilter>(
Matrix::MakeScale({2, 2, 1}), SamplerDescriptor{}),
});
// Draw a rectangle that would fully cover the parent pass size, but not
// the subpass that it is rendered in.
canvas.DrawRect(Rect::MakeLTRB(0, 0, 400, 400), {.color = Color::Green()});
// Draw a bigger rectangle to force the subpass to be bigger.
canvas.DrawRect(Rect::MakeLTRB(0, 0, 800, 800), {.color = Color::Red()});
canvas.Restore();

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

} // namespace testing
} // namespace impeller
5 changes: 3 additions & 2 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,10 @@ bool EntityPass::OnRender(
VALIDATION_LOG << SPrintF("Pass context invalid (Depth=%d)", pass_depth);
return false;
}
auto clear_color_size = pass_target.GetRenderTarget().GetRenderTargetSize();

if (!collapsed_parent_pass &&
!GetClearColor(root_pass_size).IsTransparent()) {
!GetClearColor(clear_color_size).IsTransparent()) {
// Force the pass context to create at least one new pass if the clear color
// is present.
pass_context.GetRenderPass(pass_depth);
Expand Down Expand Up @@ -897,7 +898,7 @@ bool EntityPass::OnRender(
// Skip elements that are incorporated into the clear color.
if (is_collapsing_clear_colors) {
auto [entity_color, _] =
ElementAsBackgroundColor(element, root_pass_size);
ElementAsBackgroundColor(element, clear_color_size);
if (entity_color.has_value()) {
continue;
}
Expand Down