[Impeller] migrated one test over from aiks to dl (#52786)
A redo of https://github.com/flutter/engine/pull/52711 that maintains
our existing testing patterns.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
---------
Co-authored-by: jonahwilliams <[email protected]>
diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files
index 94f1aa9..fdf367c 100644
--- a/ci/licenses_golden/excluded_files
+++ b/ci/licenses_golden/excluded_files
@@ -138,6 +138,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 0b6bb2c..8746b96 100644
--- a/display_list/dl_color.h
+++ b/display_list/dl_color.h
@@ -30,6 +30,7 @@
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 f54fbbf..b98a96e 100644
--- a/impeller/aiks/BUILD.gn
+++ b/impeller/aiks/BUILD.gn
@@ -51,6 +51,8 @@
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 85d6178..0aa9ed9 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 db15454..d423698 100644
--- a/impeller/aiks/aiks_playground.cc
+++ b/impeller/aiks/aiks_playground.cc
@@ -7,6 +7,7 @@
#include <memory>
#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 @@
return true;
}
+bool AiksPlayground::OpenPlaygroundHere(
+ const sk_sp<flutter::DisplayList>& 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 4d8a946..ee219f9 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 @@
bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
+ bool OpenPlaygroundHere(const sk_sp<flutter::DisplayList>& 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 aa19bf4..392f857 100644
--- a/impeller/display_list/BUILD.gn
+++ b/impeller/display_list/BUILD.gn
@@ -52,6 +52,7 @@
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 @@
}
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 @@
}
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 0000000..4a54beb
--- /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