From 887965c568698ca5a79d66b0fec9aee2fa556394 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 13 May 2024 16:14:18 -0700 Subject: [PATCH 1/5] [Impeller] migrated one test over from aiks to dl --- display_list/dl_color.h | 1 + impeller/aiks/BUILD.gn | 2 + impeller/aiks/aiks_path_unittests.cc | 25 ---------- impeller/aiks/aiks_playground.cc | 9 ++++ impeller/aiks/aiks_playground.h | 3 ++ impeller/display_list/BUILD.gn | 10 +++- .../display_list/aiks_dl_path_unittests.cc | 47 +++++++++++++++++++ 7 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 impeller/display_list/aiks_dl_path_unittests.cc 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/BUILD.gn b/impeller/aiks/BUILD.gn index 8c6516821241c..041e2c28de9bf 100644 --- a/impeller/aiks/BUILD.gn +++ b/impeller/aiks/BUILD.gn @@ -63,6 +63,8 @@ impeller_component("aiks_playground") { deps = [ ":aiks", "../playground:playground_test", + "//flutter/display_list", + "//flutter/impeller/display_list:display_list", ] public_deps = [ "//flutter/impeller/typographer/backends/skia:typographer_skia_backend", 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_playground.cc b/impeller/aiks/aiks_playground.cc index db1545425f771..d423698f5a483 100644 --- a/impeller/aiks/aiks_playground.cc +++ b/impeller/aiks/aiks_playground.cc @@ -7,6 +7,7 @@ #include #include "impeller/aiks/aiks_context.h" +#include "impeller/display_list/dl_dispatcher.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "impeller/typographer/typographer_context.h" @@ -63,4 +64,12 @@ bool AiksPlayground::ImGuiBegin(const char* name, return true; } +bool AiksPlayground::OpenPlaygroundHere( + const sk_sp& list) { + DlDispatcher dispatcher; + list->Dispatch(dispatcher); + Picture picture = dispatcher.EndRecordingAsPicture(); + return OpenPlaygroundHere(std::move(picture)); +} + } // namespace impeller diff --git a/impeller/aiks/aiks_playground.h b/impeller/aiks/aiks_playground.h index 4d8a94693229e..ee219f94d94a3 100644 --- a/impeller/aiks/aiks_playground.h +++ b/impeller/aiks/aiks_playground.h @@ -5,6 +5,7 @@ #ifndef FLUTTER_IMPELLER_AIKS_AIKS_PLAYGROUND_H_ #define FLUTTER_IMPELLER_AIKS_AIKS_PLAYGROUND_H_ +#include "flutter/display_list/display_list.h" #include "impeller/aiks/aiks_context.h" #include "impeller/aiks/aiks_playground_inspector.h" #include "impeller/aiks/picture.h" @@ -32,6 +33,8 @@ class AiksPlayground : public PlaygroundTest { bool OpenPlaygroundHere(AiksPlaygroundCallback callback); + bool OpenPlaygroundHere(const sk_sp& list); + static bool ImGuiBegin(const char* name, bool* p_open, ImGuiWindowFlags flags); diff --git a/impeller/display_list/BUILD.gn b/impeller/display_list/BUILD.gn index aa19bf425d897..392f857833002 100644 --- a/impeller/display_list/BUILD.gn +++ b/impeller/display_list/BUILD.gn @@ -52,6 +52,7 @@ impeller_component("display_list") { template("display_list_unittests_component") { target_name = invoker.target_name predefined_sources = [ + "aiks_dl_path_unittests.cc", "dl_golden_unittests.cc", "dl_playground.cc", "dl_playground.h", @@ -74,7 +75,12 @@ template("display_list_unittests_component") { } sources = predefined_sources + additional_sources - deps = [ + if (defined(invoker.deps)) { + deps = invoker.deps + } else { + deps = [] + } + deps += [ ":display_list", "../playground:playground_test", "//flutter/impeller/scene", @@ -88,9 +94,11 @@ template("display_list_unittests_component") { } display_list_unittests_component("display_list_unittests") { + deps = [ "//flutter/impeller/aiks:aiks_unittests" ] } display_list_unittests_component("display_list_unittests_golden") { + deps = [ "//flutter/impeller/aiks:aiks_unittests_golden" ] defines = [ "IMPELLER_GOLDEN_TESTS", "IMPELLER_ENABLE_VALIDATION=1", diff --git a/impeller/display_list/aiks_dl_path_unittests.cc b/impeller/display_list/aiks_dl_path_unittests.cc new file mode 100644 index 0000000000000..6063261a8da34 --- /dev/null +++ b/impeller/display_list/aiks_dl_path_unittests.cc @@ -0,0 +1,47 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/impeller/aiks/aiks_unittests.h" + +#include "flutter/display_list/dl_blend_mode.h" +#include "flutter/display_list/dl_builder.h" +#include "flutter/display_list/dl_color.h" +#include "flutter/display_list/dl_paint.h" +#include "flutter/display_list/effects/dl_color_filter.h" +#include "flutter/testing/testing.h" +#include "impeller/geometry/constants.h" + +namespace impeller { +namespace testing { + +using namespace flutter; + +TEST_P(AiksTest, 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 impeller From 60b8c2a77b17b7d48b5cef8eab3ee4c944ba014d Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 13 May 2024 16:51:09 -0700 Subject: [PATCH 2/5] license --- ci/licenses_golden/excluded_files | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index baeb05a703512..6f808530de0ea 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -140,6 +140,7 @@ ../../../flutter/impeller/compiler/shader_bundle_unittests.cc ../../../flutter/impeller/compiler/switches_unittests.cc ../../../flutter/impeller/core/allocator_unittests.cc +../../../flutter/impeller/display_list/aiks_dl_path_unittests.cc ../../../flutter/impeller/display_list/dl_golden_unittests.cc ../../../flutter/impeller/display_list/dl_golden_unittests.h ../../../flutter/impeller/display_list/dl_unittests.cc From 58de3f92576c809818b690731bb47296b50d1ffa Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 13 May 2024 17:19:50 -0700 Subject: [PATCH 3/5] fix test state --- impeller/display_list/aiks_dl_path_unittests.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/impeller/display_list/aiks_dl_path_unittests.cc b/impeller/display_list/aiks_dl_path_unittests.cc index 6063261a8da34..4a54beb7d4d13 100644 --- a/impeller/display_list/aiks_dl_path_unittests.cc +++ b/impeller/display_list/aiks_dl_path_unittests.cc @@ -10,7 +10,6 @@ #include "flutter/display_list/dl_paint.h" #include "flutter/display_list/effects/dl_color_filter.h" #include "flutter/testing/testing.h" -#include "impeller/geometry/constants.h" namespace impeller { namespace testing { @@ -19,8 +18,7 @@ using namespace flutter; TEST_P(AiksTest, RotateColorFilteredPath) { DisplayListBuilder builder; - builder.Transform(SkMatrix::Translate(300, 300)); - builder.Transform(SkMatrix::RotateDeg(impeller::kPiOver2)); + builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90)); SkPath arrow_stem; SkPath arrow_head; @@ -32,11 +30,12 @@ TEST_P(AiksTest, RotateColorFilteredPath) { DlBlendColorFilter::Make(DlColor::kAliceBlue(), DlBlendMode::kSrcIn); DlPaint paint; - paint.setStrokeMiter(15.0); + paint.setStrokeWidth(15.0); paint.setStrokeCap(DlStrokeCap::kRound); paint.setStrokeJoin(DlStrokeJoin::kRound); paint.setDrawStyle(DlDrawStyle::kStroke); paint.setColorFilter(filter); + paint.setColor(DlColor::kBlack()); builder.DrawPath(arrow_stem, paint); builder.DrawPath(arrow_head, paint); From 80c3d91e1f4c3d2c4a897aa04e3b30268e2a96ff Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 13 May 2024 19:05:45 -0700 Subject: [PATCH 4/5] Update aiks_dl_path_unittests.cc --- impeller/display_list/aiks_dl_path_unittests.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impeller/display_list/aiks_dl_path_unittests.cc b/impeller/display_list/aiks_dl_path_unittests.cc index 4a54beb7d4d13..57b6cb06bab56 100644 --- a/impeller/display_list/aiks_dl_path_unittests.cc +++ b/impeller/display_list/aiks_dl_path_unittests.cc @@ -18,7 +18,8 @@ using namespace flutter; TEST_P(AiksTest, RotateColorFilteredPath) { DisplayListBuilder builder; - builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90)); + // TESTING! + builder.Transform(SkMatrix::Translate(300, 300)); SkPath arrow_stem; SkPath arrow_head; From 9059fe85877263220e07b56854ecbaec258fbe69 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 13 May 2024 19:54:46 -0700 Subject: [PATCH 5/5] Update aiks_dl_path_unittests.cc --- impeller/display_list/aiks_dl_path_unittests.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/impeller/display_list/aiks_dl_path_unittests.cc b/impeller/display_list/aiks_dl_path_unittests.cc index 57b6cb06bab56..4a54beb7d4d13 100644 --- a/impeller/display_list/aiks_dl_path_unittests.cc +++ b/impeller/display_list/aiks_dl_path_unittests.cc @@ -18,8 +18,7 @@ using namespace flutter; TEST_P(AiksTest, RotateColorFilteredPath) { DisplayListBuilder builder; - // TESTING! - builder.Transform(SkMatrix::Translate(300, 300)); + builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90)); SkPath arrow_stem; SkPath arrow_head;