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 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..4a54beb7d4d13 --- /dev/null +++ b/impeller/display_list/aiks_dl_path_unittests.cc @@ -0,0 +1,46 @@ +// 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" + +namespace impeller { +namespace testing { + +using namespace flutter; + +TEST_P(AiksTest, RotateColorFilteredPath) { + DisplayListBuilder builder; + builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90)); + + 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.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); + + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} +} // namespace testing +} // namespace impeller