[Impeller] add goldens for filter optimizations. (flutter/engine#41033)

[Impeller] add goldens for filter optimizations.
This commit is contained in:
Jonah Williams 2023-04-10 13:11:45 -07:00 committed by GitHub
parent 5fdd31653e
commit 763ede53cc
2 changed files with 94 additions and 15 deletions

View File

@ -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)});

View File

@ -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<std::string> 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.");