From dbb13ec2ecabb464df926992a4ce453292b38889 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 10 May 2024 10:06:55 -0700 Subject: [PATCH 1/3] [Impeller] test if aiks golden test can be ported to DL. --- display_list/dl_color.h | 1 + impeller/aiks/aiks_path_unittests.cc | 25 --------------- impeller/display_list/dl_golden_unittests.cc | 33 +++++++++++++++++++- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/display_list/dl_color.h b/display_list/dl_color.h index 0b6bb2c21cb12..8746b96e3120d 100644 --- a/display_list/dl_color.h +++ b/display_list/dl_color.h @@ -30,6 +30,7 @@ struct DlColor { static constexpr DlColor kDarkGrey() {return DlColor(0xFF3F3F3F);}; static constexpr DlColor kMidGrey() {return DlColor(0xFF808080);}; static constexpr DlColor kLightGrey() {return DlColor(0xFFC0C0C0);}; + static constexpr DlColor kAliceBlue() {return DlColor(0xFFF0F8FF);}; // clang-format on constexpr bool isOpaque() const { return getAlpha() == 0xFF; } diff --git a/impeller/aiks/aiks_path_unittests.cc b/impeller/aiks/aiks_path_unittests.cc index 85d617856c533..0aa9ed990338d 100644 --- a/impeller/aiks/aiks_path_unittests.cc +++ b/impeller/aiks/aiks_path_unittests.cc @@ -17,31 +17,6 @@ namespace impeller { namespace testing { -TEST_P(AiksTest, RotateColorFilteredPath) { - Canvas canvas; - canvas.Concat(Matrix::MakeTranslation({300, 300})); - canvas.Concat(Matrix::MakeRotationZ(Radians(kPiOver2))); - auto arrow_stem = - PathBuilder{}.MoveTo({120, 190}).LineTo({120, 50}).TakePath(); - auto arrow_head = PathBuilder{} - .MoveTo({50, 120}) - .LineTo({120, 190}) - .LineTo({190, 120}) - .TakePath(); - auto paint = Paint{ - .stroke_width = 15.0, - .stroke_cap = Cap::kRound, - .stroke_join = Join::kRound, - .style = Paint::Style::kStroke, - .color_filter = - ColorFilter::MakeBlend(BlendMode::kSourceIn, Color::AliceBlue()), - }; - - canvas.DrawPath(arrow_stem, paint); - canvas.DrawPath(arrow_head, paint); - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); -} - TEST_P(AiksTest, CanRenderStrokes) { Canvas canvas; Paint paint; diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index 81f9e70b33d04..aaac68ec183d4 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -4,9 +4,13 @@ #include "impeller/display_list/dl_golden_unittests.h" +#include "display_list/dl_blend_mode.h" +#include "display_list/dl_color.h" +#include "display_list/dl_paint.h" +#include "display_list/effects/dl_color_filter.h" #include "flutter/display_list/dl_builder.h" -#include "flutter/testing/testing.h" #include "gtest/gtest.h" +#include "impeller/geometry/constants.h" namespace flutter { namespace testing { @@ -48,5 +52,32 @@ TEST_P(DlGoldenTest, CanRenderImage) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } +TEST_P(DlGoldenTest, RotateColorFilteredPath) { + DisplayListBuilder builder; + builder.Transform(SkMatrix::Translate(300, 300)); + builder.Transform(SkMatrix::RotateDeg(impeller::kPiOver2)); + + SkPath arrow_stem; + SkPath arrow_head; + + arrow_stem.moveTo({120, 190}).lineTo({120, 50}); + arrow_head.moveTo({50, 120}).lineTo({120, 190}).lineTo({190, 120}); + + auto filter = + DlBlendColorFilter::Make(DlColor::kAliceBlue(), DlBlendMode::kSrcIn); + + DlPaint paint; + paint.setStrokeMiter(15.0); + paint.setStrokeCap(DlStrokeCap::kRound); + paint.setStrokeJoin(DlStrokeJoin::kRound); + paint.setDrawStyle(DlDrawStyle::kStroke); + paint.setColorFilter(filter); + + builder.DrawPath(arrow_stem, paint); + builder.DrawPath(arrow_head, paint); + + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} + } // namespace testing } // namespace flutter From 34eb56105d3a0cb8ac8e45a834b4502ca2859a6b Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 10 May 2024 11:05:15 -0700 Subject: [PATCH 2/3] rename golden tests to aiks test for golden continuity. --- impeller/aiks/aiks_unittests.cc | 16 ---------------- impeller/display_list/dl_golden_unittests.cc | 10 ++++++---- testing/impeller_golden_tests_output.txt | 8 +------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 12c5414ae1b70..219366ba6adf5 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -83,15 +83,6 @@ TEST_P(AiksTest, CanRenderColoredRect) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -TEST_P(AiksTest, CanRenderImage) { - Canvas canvas; - Paint paint; - auto image = std::make_shared(CreateTextureForFixture("kalimba.jpg")); - paint.color = Color::Red(); - canvas.DrawImage(image, Point::MakeXY(100.0, 100.0), paint); - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); -} - TEST_P(AiksTest, CanRenderInvertedImageWithColorFilter) { Canvas canvas; Paint paint; @@ -921,13 +912,6 @@ TEST_P(AiksTest, TextRotated) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -TEST_P(AiksTest, CanDrawPaint) { - Canvas canvas; - canvas.Scale(Vector2(0.2, 0.2)); - canvas.DrawPaint({.color = Color::MediumTurquoise()}); - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); -} - TEST_P(AiksTest, CanDrawPaintMultipleTimes) { Canvas canvas; canvas.Scale(Vector2(0.2, 0.2)); diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index aaac68ec183d4..2d9bc9aa8e21c 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -18,9 +18,11 @@ namespace testing { using impeller::PlaygroundBackend; using impeller::PlaygroundTest; -INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); +using AiksTest = DlGoldenTest; -TEST_P(DlGoldenTest, CanDrawPaint) { +INSTANTIATE_PLAYGROUND_SUITE(AiksTest); + +TEST_P(AiksTest, CanDrawPaint) { auto draw = [](DlCanvas* canvas, const std::vector>& images) { canvas->Scale(0.2, 0.2); @@ -35,7 +37,7 @@ TEST_P(DlGoldenTest, CanDrawPaint) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } -TEST_P(DlGoldenTest, CanRenderImage) { +TEST_P(AiksTest, CanRenderImage) { auto draw = [](DlCanvas* canvas, const std::vector>& images) { FML_CHECK(images.size() >= 1); DlPaint paint; @@ -52,7 +54,7 @@ TEST_P(DlGoldenTest, CanRenderImage) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } -TEST_P(DlGoldenTest, RotateColorFilteredPath) { +TEST_P(AiksTest, RotateColorFilteredPath) { DisplayListBuilder builder; builder.Transform(SkMatrix::Translate(300, 300)); builder.Transform(SkMatrix::RotateDeg(impeller::kPiOver2)); diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index 99704781e83be..67fc0eb14d438 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -773,10 +773,4 @@ impeller_Play_AiksTest_VerticesGeometryUVPositionDataWithTranslate_OpenGLES.png impeller_Play_AiksTest_VerticesGeometryUVPositionDataWithTranslate_Vulkan.png impeller_Play_AiksTest_VerticesGeometryUVPositionData_Metal.png impeller_Play_AiksTest_VerticesGeometryUVPositionData_OpenGLES.png -impeller_Play_AiksTest_VerticesGeometryUVPositionData_Vulkan.png -impeller_Play_DlGoldenTest_CanDrawPaint_Metal.png -impeller_Play_DlGoldenTest_CanDrawPaint_OpenGLES.png -impeller_Play_DlGoldenTest_CanDrawPaint_Vulkan.png -impeller_Play_DlGoldenTest_CanRenderImage_Metal.png -impeller_Play_DlGoldenTest_CanRenderImage_OpenGLES.png -impeller_Play_DlGoldenTest_CanRenderImage_Vulkan.png \ No newline at end of file +impeller_Play_AiksTest_VerticesGeometryUVPositionData_Vulkan.png \ No newline at end of file From cb28c8ae30f431790c9660dac9d214f1a5656c14 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 10 May 2024 12:07:23 -0700 Subject: [PATCH 3/3] rename in golden harvester. --- impeller/display_list/dl_golden_unittests.cc | 10 ++++------ impeller/golden_tests/golden_playground_test_mac.cc | 3 +++ impeller/golden_tests/golden_tests.cc | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index 2d9bc9aa8e21c..aaac68ec183d4 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -18,11 +18,9 @@ namespace testing { using impeller::PlaygroundBackend; using impeller::PlaygroundTest; -using AiksTest = DlGoldenTest; +INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); -INSTANTIATE_PLAYGROUND_SUITE(AiksTest); - -TEST_P(AiksTest, CanDrawPaint) { +TEST_P(DlGoldenTest, CanDrawPaint) { auto draw = [](DlCanvas* canvas, const std::vector>& images) { canvas->Scale(0.2, 0.2); @@ -37,7 +35,7 @@ TEST_P(AiksTest, CanDrawPaint) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } -TEST_P(AiksTest, CanRenderImage) { +TEST_P(DlGoldenTest, CanRenderImage) { auto draw = [](DlCanvas* canvas, const std::vector>& images) { FML_CHECK(images.size() >= 1); DlPaint paint; @@ -54,7 +52,7 @@ TEST_P(AiksTest, CanRenderImage) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } -TEST_P(AiksTest, RotateColorFilteredPath) { +TEST_P(DlGoldenTest, RotateColorFilteredPath) { DisplayListBuilder builder; builder.Transform(SkMatrix::Translate(300, 300)); builder.Transform(SkMatrix::RotateDeg(impeller::kPiOver2)); diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index f90aaa91ed6ff..c12eeeb4af364 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -76,6 +76,9 @@ namespace { std::string GetTestName() { std::string suite_name = ::testing::UnitTest::GetInstance()->current_test_suite()->name(); + if (suite_name == "DlGoldenTest") { + suite_name = "AiksTest"; + } std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); std::stringstream ss; diff --git a/impeller/golden_tests/golden_tests.cc b/impeller/golden_tests/golden_tests.cc index 40a79cd173703..532076a3f34ef 100644 --- a/impeller/golden_tests/golden_tests.cc +++ b/impeller/golden_tests/golden_tests.cc @@ -23,6 +23,9 @@ namespace { std::string GetTestName() { std::string suite_name = ::testing::UnitTest::GetInstance()->current_test_suite()->name(); + if (suite_name == "DlGoldenTest") { + suite_name = "AiksTest"; + } std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); std::stringstream ss;