diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index be7b50c8cb347..35207daa55d8f 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -2368,6 +2368,35 @@ TEST_P(AiksTest, ClipRectElidesNoOpClips) { ASSERT_EQ(render_pass->GetCommands().size(), 0llu); } +TEST_P(AiksTest, ClearColorOptimizationDoesNotApplyForBackdropFilters) { + Canvas canvas; + canvas.SaveLayer({}, std::nullopt, + ImageFilter::MakeBlur(Sigma(3), Sigma(3), + FilterContents::BlurStyle::kNormal, + Entity::TileMode::kClamp)); + canvas.DrawPaint({.color = Color::Red(), .blend_mode = BlendMode::kSource}); + canvas.DrawPaint({.color = Color::CornflowerBlue().WithAlpha(0.75), + .blend_mode = BlendMode::kSourceOver}); + canvas.Restore(); + + Picture picture = canvas.EndRecordingAsPicture(); + + std::optional actual_color; + picture.pass->IterateAllElements([&](EntityPass::Element& element) -> bool { + if (auto subpass = std::get_if>(&element)) { + actual_color = subpass->get()->GetClearColor(); + } + // Fail if the first element isn't a subpass. + return true; + }); + + ASSERT_TRUE(actual_color.has_value()); + if (!actual_color) { + return; + } + ASSERT_EQ(actual_color.value(), Color::BlackTransparent()); +} + TEST_P(AiksTest, CollapsedDrawPaintInSubpass) { Canvas canvas; canvas.DrawPaint( diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index 6b4017ad0a19c..e4b36fee3a46d 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -1091,6 +1091,10 @@ void EntityPass::SetBlendMode(BlendMode blend_mode) { Color EntityPass::GetClearColor(ISize target_size) const { Color result = Color::BlackTransparent(); + if (backdrop_filter_proc_) { + return result; + } + for (const Element& element : elements_) { auto [entity_color, blend_mode] = ElementAsBackgroundColor(element, target_size);