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/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 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 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; 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