[Impeller] Adds impeller display list golden tests (flutter/engine#52690)
issue https://github.com/flutter/flutter/issues/146941 ## 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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -49,29 +49,52 @@ 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",
|
||||
]
|
||||
additional_sources = []
|
||||
if (defined(invoker.sources)) {
|
||||
additional_sources = invoker.sources
|
||||
}
|
||||
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" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
":display_list",
|
||||
"../playground:playground_test",
|
||||
"//flutter/impeller/scene",
|
||||
"//flutter/impeller/typographer/backends/stb:typographer_stb_backend",
|
||||
"//flutter/third_party/txt",
|
||||
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",
|
||||
]
|
||||
|
||||
if (!defined(defines)) {
|
||||
defines = []
|
||||
}
|
||||
if (impeller_enable_3d) {
|
||||
defines += [ "IMPELLER_ENABLE_3D" ]
|
||||
}
|
||||
}
|
||||
|
||||
impeller_component("skia_conversions_unittests") {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// 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"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
using impeller::PlaygroundBackend;
|
||||
using impeller::PlaygroundTest;
|
||||
|
||||
INSTANTIATE_PLAYGROUND_SUITE(DlGoldenTest);
|
||||
|
||||
TEST_P(DlGoldenTest, CanDrawPaint) {
|
||||
auto draw = [](DlCanvas* canvas,
|
||||
const std::vector<std::unique_ptr<DlImage>>& images) {
|
||||
canvas->Scale(0.2, 0.2);
|
||||
DlPaint paint;
|
||||
paint.setColor(DlColor::kCyan());
|
||||
canvas->DrawPaint(paint);
|
||||
};
|
||||
|
||||
DisplayListBuilder builder;
|
||||
draw(&builder, /*images=*/{});
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(DlGoldenTest, CanRenderImage) {
|
||||
auto draw = [](DlCanvas* canvas, const std::vector<sk_sp<DlImage>>& 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<sk_sp<DlImage>> images;
|
||||
images.emplace_back(CreateDlImageForFixture("kalimba.jpg"));
|
||||
draw(&builder, images);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -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/display_list/dl_playground.h"
|
||||
#include "impeller/golden_tests/golden_playground_test.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
#ifdef IMPELLER_GOLDEN_TESTS
|
||||
using DlGoldenTest = impeller::GoldenPlaygroundTest;
|
||||
#else
|
||||
using DlGoldenTest = impeller::DlPlayground;
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_IMPELLER_DISPLAY_LIST_DL_GOLDEN_UNITTESTS_H_
|
||||
@@ -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<flutter::DlImage> DlPlayground::CreateDlImageForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping) const {
|
||||
std::shared_ptr<fml::Mapping> mapping =
|
||||
flutter::testing::OpenFixtureAsMapping(fixture_name);
|
||||
std::shared_ptr<Texture> texture = Playground::CreateTextureForMapping(
|
||||
GetContext(), mapping, enable_mipmapping);
|
||||
if (texture) {
|
||||
texture->SetLabel(fixture_name);
|
||||
}
|
||||
return DlImageImpeller::Make(texture);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -31,6 +31,10 @@ class DlPlayground : public PlaygroundTest {
|
||||
|
||||
SkFont CreateTestFont();
|
||||
|
||||
sk_sp<flutter::DlImage> CreateDlImageForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping = false) const;
|
||||
|
||||
private:
|
||||
DlPlayground(const DlPlayground&) = delete;
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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"
|
||||
@@ -43,6 +45,8 @@ class GoldenPlaygroundTest
|
||||
|
||||
bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
|
||||
|
||||
bool OpenPlaygroundHere(const sk_sp<flutter::DisplayList>& list);
|
||||
|
||||
static bool ImGuiBegin(const char* name,
|
||||
bool* p_open,
|
||||
ImGuiWindowFlags flags);
|
||||
@@ -51,6 +55,10 @@ class GoldenPlaygroundTest
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping = false) const;
|
||||
|
||||
sk_sp<flutter::DlImage> CreateDlImageForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping = false) const;
|
||||
|
||||
RuntimeStage::Map OpenAssetAsRuntimeStage(const char* asset_name) const;
|
||||
|
||||
std::shared_ptr<Context> GetContext() const;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#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/display_list/dl_image_impeller.h"
|
||||
#include "impeller/typographer/backends/skia/typographer_context_skia.h"
|
||||
#include "impeller/typographer/typographer_context.h"
|
||||
|
||||
@@ -227,6 +229,14 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere(
|
||||
return SaveScreenshot(std::move(screenshot));
|
||||
}
|
||||
|
||||
bool GoldenPlaygroundTest::OpenPlaygroundHere(
|
||||
const sk_sp<flutter::DisplayList>& 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) {
|
||||
@@ -246,6 +256,14 @@ std::shared_ptr<Texture> GoldenPlaygroundTest::CreateTextureForFixture(
|
||||
return result;
|
||||
}
|
||||
|
||||
sk_sp<flutter::DlImage> GoldenPlaygroundTest::CreateDlImageForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping) const {
|
||||
std::shared_ptr<Texture> texture =
|
||||
CreateTextureForFixture(fixture_name, enable_mipmapping);
|
||||
return DlImageImpeller::Make(texture);
|
||||
}
|
||||
|
||||
RuntimeStage::Map GoldenPlaygroundTest::OpenAssetAsRuntimeStage(
|
||||
const char* asset_name) const {
|
||||
const std::shared_ptr<fml::Mapping> fixture =
|
||||
|
||||
@@ -37,11 +37,23 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GoldenPlaygroundTest::OpenPlaygroundHere(
|
||||
const sk_sp<flutter::DisplayList>& list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> GoldenPlaygroundTest::CreateTextureForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<flutter::DlImage> GoldenPlaygroundTest::CreateDlImageForFixture(
|
||||
const char* fixture_name,
|
||||
bool enable_mipmapping) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RuntimeStage::Map GoldenPlaygroundTest::OpenAssetAsRuntimeStage(
|
||||
const char* asset_name) const {
|
||||
return {};
|
||||
|
||||
@@ -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
|
||||
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
|
||||
Reference in New Issue
Block a user