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
77 changes: 77 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Expand Down
32 changes: 17 additions & 15 deletions impeller/golden_tests/golden_playground_test_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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.");
Expand Down