From 8cdfe115448d4490c630fd51496d217970bc41b6 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 8 May 2024 09:05:42 -0700 Subject: [PATCH 01/10] [Impeller] added display list golden test --- impeller/display_list/BUILD.gn | 1 + impeller/display_list/dl_golden_unittests.cc | 30 ++++++++++++++++++++ impeller/display_list/dl_golden_unittests.h | 23 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 impeller/display_list/dl_golden_unittests.cc create mode 100644 impeller/display_list/dl_golden_unittests.h diff --git a/impeller/display_list/BUILD.gn b/impeller/display_list/BUILD.gn index d5acdc83a74ae..ec6a8c788510e 100644 --- a/impeller/display_list/BUILD.gn +++ b/impeller/display_list/BUILD.gn @@ -53,6 +53,7 @@ impeller_component("display_list_unittests") { testonly = true sources = [ + "dl_golden_unittests.cc", "dl_playground.cc", "dl_playground.h", "dl_unittests.cc", diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc new file mode 100644 index 0000000000000..0278c57006f8e --- /dev/null +++ b/impeller/display_list/dl_golden_unittests.cc @@ -0,0 +1,30 @@ +// 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 "impeller/display_list/dl_golden_unittests.h" + +#include "flutter/display_list/dl_builder.h" +#include "flutter/testing/testing.h" +#include "gtest/gtest.h" +#include "impeller/display_list/dl_dispatcher.h" + +namespace impeller { +namespace testing { + +INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); + +TEST_P(DlGoldenTest, CanDrawPaint) { + flutter::DisplayListBuilder builder; + builder.Scale(0.2, 0.2); + flutter::DlPaint paint; + paint.setColor(flutter::DlColor::kCyan()); + builder.DrawPaint(paint); + + DlDispatcher dispatcher; + builder.Build()->Dispatch(dispatcher); + ASSERT_TRUE(OpenPlaygroundHere(dispatcher.EndRecordingAsPicture())); +} + +} // namespace testing +} // namespace impeller diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h new file mode 100644 index 0000000000000..8355d576a59fb --- /dev/null +++ b/impeller/display_list/dl_golden_unittests.h @@ -0,0 +1,23 @@ +// 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. + +#ifndef FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ +#define FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ + +#include "impeller/aiks/aiks_playground.h" +#include "impeller/golden_tests/golden_playground_test.h" + +namespace impeller { +namespace testing { + +#ifdef IMPELLER_GOLDEN_TESTS +using DlGoldenTest = GoldenPlaygroundTest; +#else +using DlGoldenTest = AiksPlayground; +#endif + +} // namespace testing +} // namespace impeller + +#endif // FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ From a72ae78e829aa6a40a5cb1ec2fc388cbcfec972f Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 8 May 2024 11:03:19 -0700 Subject: [PATCH 02/10] refactored test --- impeller/display_list/dl_golden_unittests.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index 0278c57006f8e..c54397e5feddc 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -15,11 +15,15 @@ namespace testing { INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); TEST_P(DlGoldenTest, CanDrawPaint) { + auto draw = [](flutter::DlCanvas* canvas, flutter::DlImage** images) { + canvas->Scale(0.2, 0.2); + flutter::DlPaint paint; + paint.setColor(flutter::DlColor::kCyan()); + canvas->DrawPaint(paint); + }; + flutter::DisplayListBuilder builder; - builder.Scale(0.2, 0.2); - flutter::DlPaint paint; - paint.setColor(flutter::DlColor::kCyan()); - builder.DrawPaint(paint); + draw(&builder, nullptr); DlDispatcher dispatcher; builder.Build()->Dispatch(dispatcher); From 3f83d0ca880b201ab3182f3b7064f33b39efd07e Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 8 May 2024 15:21:00 -0700 Subject: [PATCH 03/10] got goldens compiling --- impeller/display_list/BUILD.gn | 56 +++++++++++++------ impeller/display_list/dl_golden_unittests.cc | 4 +- impeller/display_list/dl_golden_unittests.h | 4 +- impeller/golden_tests/BUILD.gn | 2 + .../golden_tests/golden_playground_test.h | 3 + .../golden_playground_test_mac.cc | 9 +++ .../golden_playground_test_stub.cc | 5 ++ 7 files changed, 62 insertions(+), 21 deletions(-) diff --git a/impeller/display_list/BUILD.gn b/impeller/display_list/BUILD.gn index ec6a8c788510e..aa19bf425d897 100644 --- a/impeller/display_list/BUILD.gn +++ b/impeller/display_list/BUILD.gn @@ -49,32 +49,54 @@ impeller_component("display_list") { } } -impeller_component("display_list_unittests") { - testonly = true - - sources = [ +template("display_list_unittests_component") { + target_name = invoker.target_name + predefined_sources = [ "dl_golden_unittests.cc", "dl_playground.cc", "dl_playground.h", "dl_unittests.cc", ] - - deps = [ - ":display_list", - "../playground:playground_test", - "//flutter/impeller/scene", - "//flutter/impeller/typographer/backends/stb:typographer_stb_backend", - "//flutter/third_party/txt", - ] - - if (!defined(defines)) { - defines = [] + additional_sources = [] + if (defined(invoker.sources)) { + additional_sources = invoker.sources } - if (impeller_enable_3d) { - defines += [ "IMPELLER_ENABLE_3D" ] + impeller_component(target_name) { + testonly = true + if (defined(invoker.defines)) { + defines = invoker.defines + } else { + defines = [] + } + defines += [ "_USE_MATH_DEFINES" ] + if (impeller_enable_3d) { + defines += [ "IMPELLER_ENABLE_3D" ] + } + + sources = predefined_sources + additional_sources + deps = [ + ":display_list", + "../playground:playground_test", + "//flutter/impeller/scene", + "//flutter/impeller/typographer/backends/stb:typographer_stb_backend", + "//flutter/third_party/txt", + ] + if (defined(invoker.public_configs)) { + public_configs = invoker.public_configs + } } } +display_list_unittests_component("display_list_unittests") { +} + +display_list_unittests_component("display_list_unittests_golden") { + defines = [ + "IMPELLER_GOLDEN_TESTS", + "IMPELLER_ENABLE_VALIDATION=1", + ] +} + impeller_component("skia_conversions_unittests") { testonly = true diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index c54397e5feddc..70b667e7970c3 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -25,9 +25,7 @@ TEST_P(DlGoldenTest, CanDrawPaint) { flutter::DisplayListBuilder builder; draw(&builder, nullptr); - DlDispatcher dispatcher; - builder.Build()->Dispatch(dispatcher); - ASSERT_TRUE(OpenPlaygroundHere(dispatcher.EndRecordingAsPicture())); + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } } // namespace testing diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h index 8355d576a59fb..741a33062d817 100644 --- a/impeller/display_list/dl_golden_unittests.h +++ b/impeller/display_list/dl_golden_unittests.h @@ -6,15 +6,17 @@ #define FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ #include "impeller/aiks/aiks_playground.h" +#include "impeller/display_list/dl_playground.h" #include "impeller/golden_tests/golden_playground_test.h" + namespace impeller { namespace testing { #ifdef IMPELLER_GOLDEN_TESTS using DlGoldenTest = GoldenPlaygroundTest; #else -using DlGoldenTest = AiksPlayground; +using DlGoldenTest = DlPlayground; #endif } // namespace testing diff --git a/impeller/golden_tests/BUILD.gn b/impeller/golden_tests/BUILD.gn index 8c8b5548833e0..cd1cae7cb8d58 100644 --- a/impeller/golden_tests/BUILD.gn +++ b/impeller/golden_tests/BUILD.gn @@ -14,6 +14,7 @@ impeller_component("golden_playground_test") { ":digest", "//flutter/fml", "//flutter/impeller/aiks", + "//flutter/impeller/display_list:display_list", "//flutter/impeller/playground", "//flutter/impeller/typographer/backends/skia:typographer_skia_backend", "//flutter/testing:testing_lib", @@ -82,6 +83,7 @@ if (is_mac) { ":metal_screenshot", "//flutter/impeller/aiks", "//flutter/impeller/aiks:aiks_unittests_golden", + "//flutter/impeller/display_list:display_list_unittests_golden", "//flutter/impeller/fixtures", "//flutter/third_party/angle:libEGL", "//flutter/third_party/angle:libGLESv2", diff --git a/impeller/golden_tests/golden_playground_test.h b/impeller/golden_tests/golden_playground_test.h index f57ceb2c543a2..eac3f50fa2369 100644 --- a/impeller/golden_tests/golden_playground_test.h +++ b/impeller/golden_tests/golden_playground_test.h @@ -10,6 +10,7 @@ #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/playground/playground.h" #include "flutter/impeller/renderer/render_target.h" +#include "flutter/display_list/display_list.h" #include "flutter/testing/testing.h" #include "impeller/typographer/typographer_context.h" #include "third_party/imgui/imgui.h" @@ -43,6 +44,8 @@ class GoldenPlaygroundTest bool OpenPlaygroundHere(AiksPlaygroundCallback callback); + bool OpenPlaygroundHere(sk_sp list); + static bool ImGuiBegin(const char* name, bool* p_open, ImGuiWindowFlags flags); diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index 4fd99b49594ab..929bafe6f65e9 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -14,6 +14,7 @@ #include "flutter/impeller/golden_tests/vulkan_screenshotter.h" #include "flutter/third_party/abseil-cpp/absl/base/no_destructor.h" #include "fml/closure.h" +#include "impeller/display_list/dl_dispatcher.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "impeller/typographer/typographer_context.h" @@ -227,6 +228,14 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere( return SaveScreenshot(std::move(screenshot)); } +bool GoldenPlaygroundTest::OpenPlaygroundHere( + sk_sp list) { + DlDispatcher dispatcher; + list->Dispatch(dispatcher); + Picture picture = dispatcher.EndRecordingAsPicture(); + return OpenPlaygroundHere(std::move(picture)); +} + bool GoldenPlaygroundTest::ImGuiBegin(const char* name, bool* p_open, ImGuiWindowFlags flags) { diff --git a/impeller/golden_tests/golden_playground_test_stub.cc b/impeller/golden_tests/golden_playground_test_stub.cc index 9d7568a1faff2..05182bf241ff0 100644 --- a/impeller/golden_tests/golden_playground_test_stub.cc +++ b/impeller/golden_tests/golden_playground_test_stub.cc @@ -37,6 +37,11 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere( return false; } +bool GoldenPlaygroundTest::OpenPlaygroundHere( + sk_sp list) { + return false; +} + std::shared_ptr GoldenPlaygroundTest::CreateTextureForFixture( const char* fixture_name, bool enable_mipmapping) const { From 29c5f67b7b80cafae3037a5557d0d551b52c7521 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 8 May 2024 15:48:17 -0700 Subject: [PATCH 04/10] removed include --- impeller/display_list/dl_golden_unittests.h | 1 - 1 file changed, 1 deletion(-) diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h index 741a33062d817..4940802e60322 100644 --- a/impeller/display_list/dl_golden_unittests.h +++ b/impeller/display_list/dl_golden_unittests.h @@ -5,7 +5,6 @@ #ifndef FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ #define FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ -#include "impeller/aiks/aiks_playground.h" #include "impeller/display_list/dl_playground.h" #include "impeller/golden_tests/golden_playground_test.h" From 13077e48130649b7a7eb91aa5d058878a8c92636 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 8 May 2024 15:49:04 -0700 Subject: [PATCH 05/10] format --- impeller/display_list/dl_golden_unittests.h | 1 - impeller/golden_tests/golden_playground_test.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h index 4940802e60322..cfb77ed997a51 100644 --- a/impeller/display_list/dl_golden_unittests.h +++ b/impeller/display_list/dl_golden_unittests.h @@ -8,7 +8,6 @@ #include "impeller/display_list/dl_playground.h" #include "impeller/golden_tests/golden_playground_test.h" - namespace impeller { namespace testing { diff --git a/impeller/golden_tests/golden_playground_test.h b/impeller/golden_tests/golden_playground_test.h index eac3f50fa2369..d78d4ea483cec 100644 --- a/impeller/golden_tests/golden_playground_test.h +++ b/impeller/golden_tests/golden_playground_test.h @@ -7,10 +7,10 @@ #include +#include "flutter/display_list/display_list.h" #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/playground/playground.h" #include "flutter/impeller/renderer/render_target.h" -#include "flutter/display_list/display_list.h" #include "flutter/testing/testing.h" #include "impeller/typographer/typographer_context.h" #include "third_party/imgui/imgui.h" From b1ec721fc960ebffc1ed5839014e99ceb86195c7 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 9 May 2024 09:58:51 -0700 Subject: [PATCH 06/10] license / tidy --- ci/licenses_golden/excluded_files | 2 ++ impeller/golden_tests/golden_playground_test.h | 2 +- impeller/golden_tests/golden_playground_test_mac.cc | 2 +- impeller/golden_tests/golden_playground_test_stub.cc | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index 76840d4082d30..baeb05a703512 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -140,6 +140,8 @@ ../../../flutter/impeller/compiler/shader_bundle_unittests.cc ../../../flutter/impeller/compiler/switches_unittests.cc ../../../flutter/impeller/core/allocator_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 ../../../flutter/impeller/display_list/skia_conversions_unittests.cc ../../../flutter/impeller/docs diff --git a/impeller/golden_tests/golden_playground_test.h b/impeller/golden_tests/golden_playground_test.h index d78d4ea483cec..c74001f353a64 100644 --- a/impeller/golden_tests/golden_playground_test.h +++ b/impeller/golden_tests/golden_playground_test.h @@ -44,7 +44,7 @@ class GoldenPlaygroundTest bool OpenPlaygroundHere(AiksPlaygroundCallback callback); - bool OpenPlaygroundHere(sk_sp list); + bool OpenPlaygroundHere(const sk_sp& list); static bool ImGuiBegin(const char* name, bool* p_open, diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index 929bafe6f65e9..ab4c518f65b4e 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -229,7 +229,7 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere( } bool GoldenPlaygroundTest::OpenPlaygroundHere( - sk_sp list) { + const sk_sp& list) { DlDispatcher dispatcher; list->Dispatch(dispatcher); Picture picture = dispatcher.EndRecordingAsPicture(); diff --git a/impeller/golden_tests/golden_playground_test_stub.cc b/impeller/golden_tests/golden_playground_test_stub.cc index 05182bf241ff0..6c6fde8ab7442 100644 --- a/impeller/golden_tests/golden_playground_test_stub.cc +++ b/impeller/golden_tests/golden_playground_test_stub.cc @@ -38,7 +38,7 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere( } bool GoldenPlaygroundTest::OpenPlaygroundHere( - sk_sp list) { + const sk_sp& list) { return false; } From 70586a5635cdd46895e9681f2074ca2daec641dd Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 9 May 2024 10:32:19 -0700 Subject: [PATCH 07/10] moved the test to the flutter namespace --- impeller/display_list/dl_golden_unittests.cc | 17 ++++++++++------- impeller/display_list/dl_golden_unittests.h | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index 70b667e7970c3..f4493a9b861af 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -7,23 +7,26 @@ #include "flutter/display_list/dl_builder.h" #include "flutter/testing/testing.h" #include "gtest/gtest.h" -#include "impeller/display_list/dl_dispatcher.h" -namespace impeller { +namespace flutter { namespace testing { +using impeller::PlaygroundBackend; +using impeller::PlaygroundTest; + INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest); TEST_P(DlGoldenTest, CanDrawPaint) { - auto draw = [](flutter::DlCanvas* canvas, flutter::DlImage** images) { + auto draw = [](DlCanvas* canvas, + const std::vector>& images) { canvas->Scale(0.2, 0.2); - flutter::DlPaint paint; - paint.setColor(flutter::DlColor::kCyan()); + DlPaint paint; + paint.setColor(DlColor::kCyan()); canvas->DrawPaint(paint); }; - flutter::DisplayListBuilder builder; - draw(&builder, nullptr); + DisplayListBuilder builder; + draw(&builder, /*images=*/{}); ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h index cfb77ed997a51..d48962bfa567c 100644 --- a/impeller/display_list/dl_golden_unittests.h +++ b/impeller/display_list/dl_golden_unittests.h @@ -8,13 +8,13 @@ #include "impeller/display_list/dl_playground.h" #include "impeller/golden_tests/golden_playground_test.h" -namespace impeller { +namespace flutter { namespace testing { #ifdef IMPELLER_GOLDEN_TESTS -using DlGoldenTest = GoldenPlaygroundTest; +using DlGoldenTest = impeller::GoldenPlaygroundTest; #else -using DlGoldenTest = DlPlayground; +using DlGoldenTest = impeller::DlPlayground; #endif } // namespace testing From 83309eab7ffba96021d14fde86dfcb72fc9c2641 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 9 May 2024 11:06:54 -0700 Subject: [PATCH 08/10] added test that draws image for goldens --- impeller/display_list/dl_golden_unittests.cc | 19 ++++++++++++++++++- impeller/display_list/dl_golden_unittests.h | 2 +- .../golden_tests/golden_playground_test.h | 5 +++++ .../golden_playground_test_mac.cc | 9 +++++++++ .../golden_playground_test_stub.cc | 7 +++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/impeller/display_list/dl_golden_unittests.cc b/impeller/display_list/dl_golden_unittests.cc index f4493a9b861af..81f9e70b33d04 100644 --- a/impeller/display_list/dl_golden_unittests.cc +++ b/impeller/display_list/dl_golden_unittests.cc @@ -31,5 +31,22 @@ TEST_P(DlGoldenTest, CanDrawPaint) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } +TEST_P(DlGoldenTest, CanRenderImage) { + auto draw = [](DlCanvas* canvas, const std::vector>& images) { + FML_CHECK(images.size() >= 1); + DlPaint paint; + paint.setColor(DlColor::kRed()); + canvas->DrawImage(images[0], SkPoint::Make(100.0, 100.0), + DlImageSampling::kLinear, &paint); + }; + + DisplayListBuilder builder; + std::vector> images; + images.emplace_back(CreateDlImageForFixture("kalimba.jpg")); + draw(&builder, images); + + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} + } // namespace testing -} // namespace impeller +} // namespace flutter diff --git a/impeller/display_list/dl_golden_unittests.h b/impeller/display_list/dl_golden_unittests.h index d48962bfa567c..2722066822a4f 100644 --- a/impeller/display_list/dl_golden_unittests.h +++ b/impeller/display_list/dl_golden_unittests.h @@ -18,6 +18,6 @@ using DlGoldenTest = impeller::DlPlayground; #endif } // namespace testing -} // namespace impeller +} // namespace flutter #endif // FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_ diff --git a/impeller/golden_tests/golden_playground_test.h b/impeller/golden_tests/golden_playground_test.h index c74001f353a64..5fdf6720db764 100644 --- a/impeller/golden_tests/golden_playground_test.h +++ b/impeller/golden_tests/golden_playground_test.h @@ -8,6 +8,7 @@ #include #include "flutter/display_list/display_list.h" +#include "flutter/display_list/image/dl_image.h" #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/playground/playground.h" #include "flutter/impeller/renderer/render_target.h" @@ -54,6 +55,10 @@ class GoldenPlaygroundTest const char* fixture_name, bool enable_mipmapping = false) const; + sk_sp CreateDlImageForFixture( + const char* fixture_name, + bool enable_mipmapping = false) const; + RuntimeStage::Map OpenAssetAsRuntimeStage(const char* asset_name) const; std::shared_ptr GetContext() const; diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index ab4c518f65b4e..f90aaa91ed6ff 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -15,6 +15,7 @@ #include "flutter/third_party/abseil-cpp/absl/base/no_destructor.h" #include "fml/closure.h" #include "impeller/display_list/dl_dispatcher.h" +#include "impeller/display_list/dl_image_impeller.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "impeller/typographer/typographer_context.h" @@ -255,6 +256,14 @@ std::shared_ptr GoldenPlaygroundTest::CreateTextureForFixture( return result; } +sk_sp GoldenPlaygroundTest::CreateDlImageForFixture( + const char* fixture_name, + bool enable_mipmapping) const { + std::shared_ptr texture = + CreateTextureForFixture(fixture_name, enable_mipmapping); + return DlImageImpeller::Make(texture); +} + RuntimeStage::Map GoldenPlaygroundTest::OpenAssetAsRuntimeStage( const char* asset_name) const { const std::shared_ptr fixture = diff --git a/impeller/golden_tests/golden_playground_test_stub.cc b/impeller/golden_tests/golden_playground_test_stub.cc index 6c6fde8ab7442..bfdb0495e36ae 100644 --- a/impeller/golden_tests/golden_playground_test_stub.cc +++ b/impeller/golden_tests/golden_playground_test_stub.cc @@ -47,6 +47,13 @@ std::shared_ptr GoldenPlaygroundTest::CreateTextureForFixture( bool enable_mipmapping) const { return nullptr; } + +sk_sp GoldenPlaygroundTest::CreateDlImageForFixture( + const char* fixture_name, + bool enable_mipmapping) const { + return nullptr; +} + RuntimeStage::Map GoldenPlaygroundTest::OpenAssetAsRuntimeStage( const char* asset_name) const { return {}; From c3fc36084b351a1177c2e42e7ec5d0df186cbfd0 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 9 May 2024 11:11:07 -0700 Subject: [PATCH 09/10] added image to playground tests --- impeller/display_list/dl_playground.cc | 14 ++++++++++++++ impeller/display_list/dl_playground.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/impeller/display_list/dl_playground.cc b/impeller/display_list/dl_playground.cc index ef33e13bc8b13..3378df47a2ec9 100644 --- a/impeller/display_list/dl_playground.cc +++ b/impeller/display_list/dl_playground.cc @@ -7,6 +7,7 @@ #include "flutter/testing/testing.h" #include "impeller/aiks/aiks_context.h" #include "impeller/display_list/dl_dispatcher.h" +#include "impeller/display_list/dl_image_impeller.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "third_party/imgui/imgui.h" #include "third_party/skia/include/core/SkData.h" @@ -82,4 +83,17 @@ SkFont DlPlayground::CreateTestFont() { return CreateTestFontOfSize(50); } +sk_sp DlPlayground::CreateDlImageForFixture( + const char* fixture_name, + bool enable_mipmapping) const { + std::shared_ptr mapping = + flutter::testing::OpenFixtureAsMapping(fixture_name); + std::shared_ptr texture = Playground::CreateTextureForMapping( + GetContext(), mapping, enable_mipmapping); + if (texture) { + texture->SetLabel(fixture_name); + } + return DlImageImpeller::Make(texture); +} + } // namespace impeller diff --git a/impeller/display_list/dl_playground.h b/impeller/display_list/dl_playground.h index b49b1a556e156..3bc9e48d97733 100644 --- a/impeller/display_list/dl_playground.h +++ b/impeller/display_list/dl_playground.h @@ -31,6 +31,10 @@ class DlPlayground : public PlaygroundTest { SkFont CreateTestFont(); + sk_sp CreateDlImageForFixture( + const char* fixture_name, + bool enable_mipmapping = false) const; + private: DlPlayground(const DlPlayground&) = delete; From 32b911c5bca3d3e91adadce700cba93340612891 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 9 May 2024 12:35:37 -0700 Subject: [PATCH 10/10] updated golden golden --- testing/impeller_golden_tests_output.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index 67fc0eb14d438..99704781e83be 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -773,4 +773,10 @@ 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 \ No newline at end of file +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