Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e2a31e4

Browse files
author
Jonah Williams
authored
[Impeller] add goldens for filter optimizations. (#41033)
[Impeller] add goldens for filter optimizations.
1 parent a3e4c44 commit e2a31e4

File tree

2 files changed

+94
-15
lines changed

2 files changed

+94
-15
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,83 @@ TEST_P(AiksTest, DrawPaintAbsorbsClears) {
18801880
ASSERT_EQ(picture.pass->GetClearColor(), Color::CornflowerBlue());
18811881
}
18821882

1883+
TEST_P(AiksTest, ForegroundBlendSubpassCollapseOptimization) {
1884+
Canvas canvas;
1885+
1886+
canvas.SaveLayer({
1887+
.color_filter =
1888+
[](FilterInput::Ref input) {
1889+
return ColorFilterContents::MakeBlend(
1890+
BlendMode::kColorDodge, {std::move(input)}, Color::Red());
1891+
},
1892+
});
1893+
1894+
canvas.Translate({500, 300, 0});
1895+
canvas.Rotate(Radians(2 * kPi / 3));
1896+
canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()});
1897+
1898+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1899+
}
1900+
1901+
TEST_P(AiksTest, ColorMatrixFilterSubpassCollapseOptimization) {
1902+
Canvas canvas;
1903+
1904+
canvas.SaveLayer({
1905+
.color_filter =
1906+
[](FilterInput::Ref input) {
1907+
return ColorFilterContents::MakeColorMatrix(
1908+
std::move(input), {.array = {
1909+
-1.0, 0, 0, 1.0, 0, //
1910+
0, -1.0, 0, 1.0, 0, //
1911+
0, 0, -1.0, 1.0, 0, //
1912+
1.0, 1.0, 1.0, 1.0, 0 //
1913+
}});
1914+
},
1915+
});
1916+
1917+
canvas.Translate({500, 300, 0});
1918+
canvas.Rotate(Radians(2 * kPi / 3));
1919+
canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()});
1920+
1921+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1922+
}
1923+
1924+
TEST_P(AiksTest, LinearToSrgbFilterSubpassCollapseOptimization) {
1925+
Canvas canvas;
1926+
1927+
canvas.SaveLayer({
1928+
.color_filter =
1929+
[](FilterInput::Ref input) {
1930+
return ColorFilterContents::MakeLinearToSrgbFilter(
1931+
std::move(input));
1932+
},
1933+
});
1934+
1935+
canvas.Translate({500, 300, 0});
1936+
canvas.Rotate(Radians(2 * kPi / 3));
1937+
canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()});
1938+
1939+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1940+
}
1941+
1942+
TEST_P(AiksTest, SrgbToLinearFilterSubpassCollapseOptimization) {
1943+
Canvas canvas;
1944+
1945+
canvas.SaveLayer({
1946+
.color_filter =
1947+
[](FilterInput::Ref input) {
1948+
return ColorFilterContents::MakeSrgbToLinearFilter(
1949+
std::move(input));
1950+
},
1951+
});
1952+
1953+
canvas.Translate({500, 300, 0});
1954+
canvas.Rotate(Radians(2 * kPi / 3));
1955+
canvas.DrawRect({100, 100, 200, 200}, {.color = Color::Blue()});
1956+
1957+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1958+
}
1959+
18831960
static Picture BlendModeSaveLayerTest(BlendMode blend_mode) {
18841961
Canvas canvas;
18851962
canvas.DrawPaint({.color = Color::CornflowerBlue().WithAlpha(0.75)});

impeller/golden_tests/golden_playground_test_mac.cc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010

1111
namespace impeller {
1212

13+
// If you add a new playground test to the aiks unittests and you do not want it
14+
// to also be a golden test, then add the test name here.
15+
static const std::vector<std::string> kSkipTests = {
16+
"impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_Metal",
17+
"impeller_Play_AiksTest_CanRenderRadialGradient_Metal",
18+
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal",
19+
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal",
20+
"impeller_Play_AiksTest_ColorWheel_Metal",
21+
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal",
22+
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal",
23+
"impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_"
24+
"Metal",
25+
"impeller_Play_AiksTest_SceneColorSource_Metal",
26+
};
27+
1328
namespace {
1429
std::string GetTestName() {
1530
std::string suite_name =
@@ -57,21 +72,8 @@ void GoldenPlaygroundTest::SetUp() {
5772
}
5873

5974
std::string test_name = GetTestName();
60-
if (test_name ==
61-
"impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_"
62-
"Metal" ||
63-
test_name == "impeller_Play_AiksTest_CanRenderRadialGradient_Metal" ||
64-
test_name ==
65-
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal" ||
66-
test_name == "impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal" ||
67-
test_name == "impeller_Play_AiksTest_ColorWheel_Metal" ||
68-
test_name == "impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal" ||
69-
test_name ==
70-
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal" ||
71-
test_name ==
72-
"impeller_Play_AiksTest_"
73-
"CoverageOriginShouldBeAccountedForInSubpasses_Metal" ||
74-
test_name == "impeller_Play_AiksTest_SceneColorSource_Metal") {
75+
if (std::find(kSkipTests.begin(), kSkipTests.end(), test_name) !=
76+
kSkipTests.end()) {
7577
GTEST_SKIP_(
7678
"GoldenPlaygroundTest doesn't support interactive playground tests "
7779
"yet.");

0 commit comments

Comments
 (0)