diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 1732186471271..9266f0e3a17c9 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -1880,6 +1880,83 @@ TEST_P(AiksTest, DrawPaintAbsorbsClears) { ASSERT_EQ(picture.pass->GetClearColor(), Color::CornflowerBlue()); } +TEST_P(AiksTest, ForegroundBlendSubpassCollapseOptimization) { + Canvas canvas; + + canvas.SaveLayer({ + .color_filter = + [](FilterInput::Ref input) { + return ColorFilterContents::MakeBlend( + BlendMode::kColorDodge, {std::move(input)}, Color::Red()); + }, + }); + + canvas.Translate({500, 300, 0}); + canvas.Rotate(Radians(2 * kPi / 3)); + canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()}); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + +TEST_P(AiksTest, ColorMatrixFilterSubpassCollapseOptimization) { + Canvas canvas; + + canvas.SaveLayer({ + .color_filter = + [](FilterInput::Ref input) { + return ColorFilterContents::MakeColorMatrix( + std::move(input), {.array = { + -1.0, 0, 0, 1.0, 0, // + 0, -1.0, 0, 1.0, 0, // + 0, 0, -1.0, 1.0, 0, // + 1.0, 1.0, 1.0, 1.0, 0 // + }}); + }, + }); + + canvas.Translate({500, 300, 0}); + canvas.Rotate(Radians(2 * kPi / 3)); + canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()}); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + +TEST_P(AiksTest, LinearToSrgbFilterSubpassCollapseOptimization) { + Canvas canvas; + + canvas.SaveLayer({ + .color_filter = + [](FilterInput::Ref input) { + return ColorFilterContents::MakeLinearToSrgbFilter( + std::move(input)); + }, + }); + + canvas.Translate({500, 300, 0}); + canvas.Rotate(Radians(2 * kPi / 3)); + canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()}); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + +TEST_P(AiksTest, SrgbToLinearFilterSubpassCollapseOptimization) { + Canvas canvas; + + canvas.SaveLayer({ + .color_filter = + [](FilterInput::Ref input) { + return ColorFilterContents::MakeSrgbToLinearFilter( + std::move(input)); + }, + }); + + canvas.Translate({500, 300, 0}); + canvas.Rotate(Radians(2 * kPi / 3)); + canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()}); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + static Picture BlendModeSaveLayerTest(BlendMode blend_mode) { Canvas canvas; canvas.DrawPaint({.color = Color::CornflowerBlue().WithAlpha(0.75)}); diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index a4bfa29ab1350..21323d9887d03 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -10,6 +10,21 @@ namespace impeller { +// If you add a new playground test to the aiks unittests and you do not want it +// to also be a golden test, then add the test name here. +static const std::vector kSkipTests = { + "impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_Metal", + "impeller_Play_AiksTest_CanRenderRadialGradient_Metal", + "impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal", + "impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal", + "impeller_Play_AiksTest_ColorWheel_Metal", + "impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal", + "impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal", + "impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_" + "Metal", + "impeller_Play_AiksTest_SceneColorSource_Metal", +}; + namespace { std::string GetTestName() { std::string suite_name = @@ -57,21 +72,8 @@ void GoldenPlaygroundTest::SetUp() { } std::string test_name = GetTestName(); - if (test_name == - "impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_" - "Metal" || - test_name == "impeller_Play_AiksTest_CanRenderRadialGradient_Metal" || - test_name == - "impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal" || - test_name == "impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal" || - test_name == "impeller_Play_AiksTest_ColorWheel_Metal" || - test_name == "impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal" || - test_name == - "impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal" || - test_name == - "impeller_Play_AiksTest_" - "CoverageOriginShouldBeAccountedForInSubpasses_Metal" || - test_name == "impeller_Play_AiksTest_SceneColorSource_Metal") { + if (std::find(kSkipTests.begin(), kSkipTests.end(), test_name) != + kSkipTests.end()) { GTEST_SKIP_( "GoldenPlaygroundTest doesn't support interactive playground tests " "yet.");