add support to run dl_canvas_unittests on GPU surfaces (off by default) (flutter/engine#38993)
* add support to run dl_canvas_unittests on GPU surfaces (off by default) * empty commit to trigger build * conditionally include platform-specific surface provider headers * ignore DL test files during license checks * typo * add dependencies to rendertests to hopefully build on Windows * remove benchmarking deps from dl_rendertests * more changes to get Windows rendertests to link * add --enable-gl synonym and prevent non-SW surface provider dest on Windows * fix gn formatting * review feedback
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
../../../flutter/display_list/display_list_unittests.cc
|
||||
../../../flutter/display_list/display_list_utils_unittests.cc
|
||||
../../../flutter/display_list/display_list_vertices_unittests.cc
|
||||
../../../flutter/display_list/testing
|
||||
../../../flutter/docs
|
||||
../../../flutter/examples
|
||||
../../../flutter/flow/README.md
|
||||
|
||||
@@ -822,16 +822,8 @@ ORIGIN: ../../../flutter/common/task_runners.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_attributes.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_attributes_testing.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_canvas_provider.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_gl.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_gl.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_metal.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_metal.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_software.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_benchmarks_software.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_blend_mode.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_blend_mode.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_builder.cc + ../../../flutter/LICENSE
|
||||
@@ -881,8 +873,6 @@ ORIGIN: ../../../flutter/display_list/display_list_rtree.h + ../../../flutter/LI
|
||||
ORIGIN: ../../../flutter/display_list/display_list_runtime_effect.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_runtime_effect.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_sampling_options.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_test_utils.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_test_utils.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_tile_mode.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_utils.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/display_list/display_list_utils.h + ../../../flutter/LICENSE
|
||||
@@ -3309,16 +3299,8 @@ FILE: ../../../flutter/common/task_runners.h
|
||||
FILE: ../../../flutter/display_list/display_list.cc
|
||||
FILE: ../../../flutter/display_list/display_list.h
|
||||
FILE: ../../../flutter/display_list/display_list_attributes.h
|
||||
FILE: ../../../flutter/display_list/display_list_attributes_testing.h
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks.cc
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks.h
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_canvas_provider.h
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_gl.cc
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_gl.h
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_metal.cc
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_metal.h
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_software.cc
|
||||
FILE: ../../../flutter/display_list/display_list_benchmarks_software.h
|
||||
FILE: ../../../flutter/display_list/display_list_blend_mode.cc
|
||||
FILE: ../../../flutter/display_list/display_list_blend_mode.h
|
||||
FILE: ../../../flutter/display_list/display_list_builder.cc
|
||||
@@ -3368,8 +3350,6 @@ FILE: ../../../flutter/display_list/display_list_rtree.h
|
||||
FILE: ../../../flutter/display_list/display_list_runtime_effect.cc
|
||||
FILE: ../../../flutter/display_list/display_list_runtime_effect.h
|
||||
FILE: ../../../flutter/display_list/display_list_sampling_options.h
|
||||
FILE: ../../../flutter/display_list/display_list_test_utils.cc
|
||||
FILE: ../../../flutter/display_list/display_list_test_utils.h
|
||||
FILE: ../../../flutter/display_list/display_list_tile_mode.h
|
||||
FILE: ../../../flutter/display_list/display_list_utils.cc
|
||||
FILE: ../../../flutter/display_list/display_list_utils.h
|
||||
|
||||
@@ -86,23 +86,6 @@ if (enable_unittests) {
|
||||
fixtures = []
|
||||
}
|
||||
|
||||
source_set("display_list_testing") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"display_list_attributes_testing.h",
|
||||
"display_list_test_utils.cc",
|
||||
"display_list_test_utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//flutter/testing:testing_lib",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
public_deps = [ ":display_list" ]
|
||||
}
|
||||
|
||||
executable("display_list_unittests") {
|
||||
testonly = true
|
||||
|
||||
@@ -126,7 +109,7 @@ if (enable_unittests) {
|
||||
deps = [
|
||||
":display_list",
|
||||
":display_list_fixtures",
|
||||
":display_list_testing",
|
||||
"//flutter/display_list/testing:display_list_testing",
|
||||
"//flutter/testing",
|
||||
]
|
||||
|
||||
@@ -153,7 +136,8 @@ if (enable_unittests) {
|
||||
deps = [
|
||||
":display_list",
|
||||
":display_list_fixtures",
|
||||
":display_list_testing",
|
||||
"//flutter/display_list/testing:display_list_surface_provider",
|
||||
"//flutter/display_list/testing:display_list_testing",
|
||||
"//flutter/testing",
|
||||
]
|
||||
|
||||
@@ -180,8 +164,8 @@ if (enable_unittests) {
|
||||
deps = [
|
||||
":display_list",
|
||||
":display_list_fixtures",
|
||||
":display_list_testing",
|
||||
"//flutter/benchmarking",
|
||||
"//flutter/display_list/testing:display_list_testing",
|
||||
"//flutter/testing:testing_lib",
|
||||
]
|
||||
}
|
||||
@@ -204,64 +188,13 @@ source_set("display_list_benchmarks_source") {
|
||||
":display_list_benchmarks_fixtures",
|
||||
"//flutter/benchmarking",
|
||||
"//flutter/common/graphics",
|
||||
"//flutter/display_list/testing:display_list_surface_provider",
|
||||
"//flutter/fml",
|
||||
"//flutter/testing:skia",
|
||||
"//flutter/testing:testing_lib",
|
||||
"//third_party/dart/runtime:libdart_jit", # for tracing
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
defines = []
|
||||
|
||||
if (is_android) {
|
||||
libs = [
|
||||
"android",
|
||||
"EGL",
|
||||
"GLESv2",
|
||||
]
|
||||
}
|
||||
|
||||
# We only do software benchmarks on non-mobile platforms
|
||||
if (!is_android && !is_ios) {
|
||||
sources += [
|
||||
"display_list_benchmarks_software.cc",
|
||||
"display_list_benchmarks_software.h",
|
||||
]
|
||||
defines += [ "ENABLE_SOFTWARE_BENCHMARKS" ]
|
||||
}
|
||||
|
||||
# iOS and Fuchsia don't support OpenGL
|
||||
_enable_gl_benchmarks = !is_fuchsia && !is_ios
|
||||
|
||||
# TODO (https://github.com/flutter/flutter/issues/107357):
|
||||
# impeller_enable_vulkan currently requires skia to not use VMA, which inturn
|
||||
# causes linkage problems with swiftshader.
|
||||
if (impeller_enable_vulkan) {
|
||||
_enable_gl_benchmarks = false
|
||||
}
|
||||
|
||||
if (_enable_gl_benchmarks) {
|
||||
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
|
||||
sources += [
|
||||
"display_list_benchmarks_gl.cc",
|
||||
"display_list_benchmarks_gl.h",
|
||||
]
|
||||
deps += [ "//flutter/testing:opengl" ]
|
||||
}
|
||||
|
||||
if (is_mac || is_ios) {
|
||||
defines += [ "ENABLE_METAL_BENCHMARKS" ]
|
||||
sources += [
|
||||
"display_list_benchmarks_metal.cc",
|
||||
"display_list_benchmarks_metal.h",
|
||||
]
|
||||
deps += [ "//flutter/testing:metal" ]
|
||||
}
|
||||
|
||||
# Don't snapshot test results on mobile platforms
|
||||
if (is_android || is_ios) {
|
||||
defines += [ "BENCHMARKS_NO_SNAPSHOT" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("display_list_benchmarks") {
|
||||
|
||||
@@ -13,27 +13,6 @@
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
std::unique_ptr<CanvasProvider> CreateCanvasProvider(BackendType backend_type) {
|
||||
switch (backend_type) {
|
||||
#ifdef ENABLE_SOFTWARE_BENCHMARKS
|
||||
case kSoftware_Backend:
|
||||
return std::make_unique<SoftwareCanvasProvider>();
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL_BENCHMARKS
|
||||
case kOpenGL_Backend:
|
||||
return std::make_unique<OpenGLCanvasProvider>();
|
||||
#endif
|
||||
#ifdef ENABLE_METAL_BENCHMARKS
|
||||
case kMetal_Backend:
|
||||
return std::make_unique<MetalCanvasProvider>();
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkPaint GetPaintForRun(unsigned attributes) {
|
||||
SkPaint paint;
|
||||
|
||||
@@ -95,7 +74,7 @@ constexpr size_t kFixedCanvasSize = 1024;
|
||||
void BM_DrawLine(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawLineFlags);
|
||||
@@ -103,8 +82,9 @@ void BM_DrawLine(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
state.counters["DrawCallCount"] = kLinesToDraw;
|
||||
for (size_t i = 0; i < kLinesToDraw; i++) {
|
||||
@@ -117,12 +97,12 @@ void BM_DrawLine(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawLine-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawLine-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of square rects of the requested width across
|
||||
@@ -132,7 +112,7 @@ void BM_DrawLine(benchmark::State& state,
|
||||
void BM_DrawRect(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawRectFlags);
|
||||
@@ -140,8 +120,9 @@ void BM_DrawRect(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
// As rects have SkScalar dimensions, we want to ensure that we also
|
||||
// draw rects with non-integer position and size
|
||||
@@ -165,12 +146,12 @@ void BM_DrawRect(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawRect-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawRect-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of ovals of the requested height with aspect ratio 3:2 across
|
||||
@@ -180,7 +161,7 @@ void BM_DrawRect(benchmark::State& state,
|
||||
void BM_DrawOval(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawOvalFlags);
|
||||
@@ -188,8 +169,9 @@ void BM_DrawOval(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkRect rect = SkRect::MakeXYWH(0, 0, length * 1.5f, length);
|
||||
const SkScalar offset = 0.5f;
|
||||
@@ -210,12 +192,12 @@ void BM_DrawOval(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawOval-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawOval-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of circles of the requested radius across
|
||||
@@ -225,7 +207,7 @@ void BM_DrawOval(benchmark::State& state,
|
||||
void BM_DrawCircle(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawCircleFlags);
|
||||
@@ -233,8 +215,9 @@ void BM_DrawCircle(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkScalar radius = length / 2.0f;
|
||||
const SkScalar offset = 0.5f;
|
||||
@@ -257,12 +240,12 @@ void BM_DrawCircle(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawCircle-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawCircle-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of rounded rects of the requested width across
|
||||
@@ -273,7 +256,7 @@ void BM_DrawRRect(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
SkRRect::Type type) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawRRectFlags);
|
||||
@@ -281,8 +264,9 @@ void BM_DrawRRect(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkVector radii[4] = {};
|
||||
switch (type) {
|
||||
@@ -334,12 +318,12 @@ void BM_DrawRRect(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawRRect-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawRRect-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of "DR" rects of the requested width across
|
||||
@@ -353,7 +337,7 @@ void BM_DrawDRRect(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
SkRRect::Type type) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawDRRectFlags);
|
||||
@@ -361,8 +345,9 @@ void BM_DrawDRRect(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkVector radii[4] = {};
|
||||
switch (type) {
|
||||
@@ -415,18 +400,18 @@ void BM_DrawDRRect(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawDRRect-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawDRRect-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
void BM_DrawArc(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawArcNoCenterFlags);
|
||||
@@ -435,8 +420,9 @@ void BM_DrawArc(benchmark::State& state,
|
||||
|
||||
size_t length = state.range(0);
|
||||
size_t canvas_size = length * 2;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkScalar starting_angle = 0.0f;
|
||||
SkScalar offset = 0.5f;
|
||||
@@ -467,12 +453,12 @@ void BM_DrawArc(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawArc-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawArc-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Returns a list of SkPoints that represent `n` points equally spaced out
|
||||
@@ -641,15 +627,16 @@ void BM_DrawPath(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
SkPath::Verb type) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawPathFlags);
|
||||
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawPathFlags);
|
||||
|
||||
size_t length = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkPath path;
|
||||
|
||||
@@ -669,12 +656,12 @@ void BM_DrawPath(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawPath-" + label + "-" +
|
||||
std::to_string(state.range(0)) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
auto filename = surface_provider->backend_name() + "-DrawPath-" + label +
|
||||
"-" + std::to_string(state.range(0)) + ".png";
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Returns a set of vertices that describe a circle that has a
|
||||
@@ -778,15 +765,16 @@ void BM_DrawVertices(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
DlVertexMode mode) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawVerticesFlags);
|
||||
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawVerticesFlags);
|
||||
|
||||
size_t length = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkPoint center = SkPoint::Make(length / 2.0f, length / 2.0f);
|
||||
|
||||
@@ -814,13 +802,13 @@ void BM_DrawVertices(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawVertices-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawVertices-" +
|
||||
std::to_string(disc_count) + "-" + VertexModeToString(mode) +
|
||||
".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Generate `count` test points.
|
||||
@@ -873,7 +861,7 @@ void BM_DrawPoints(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
SkCanvas::PointMode mode) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
SkPaint paint;
|
||||
switch (mode) {
|
||||
@@ -901,8 +889,9 @@ void BM_DrawPoints(benchmark::State& state,
|
||||
}
|
||||
|
||||
size_t length = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
size_t point_count = state.range(0);
|
||||
state.SetComplexityN(point_count);
|
||||
@@ -917,13 +906,13 @@ void BM_DrawPoints(benchmark::State& state,
|
||||
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawPoints-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawPoints-" +
|
||||
PointModeToString(mode) + "-" + std::to_string(point_count) +
|
||||
".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> ImageFromBitmapWithNewID(const SkBitmap& bitmap) {
|
||||
@@ -942,7 +931,7 @@ void BM_DrawImage(benchmark::State& state,
|
||||
unsigned attributes,
|
||||
DlImageSampling options,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawImageWithPaintFlags);
|
||||
@@ -951,10 +940,12 @@ void BM_DrawImage(benchmark::State& state,
|
||||
|
||||
size_t bitmap_size = state.range(0);
|
||||
size_t canvas_size = 2 * bitmap_size;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
sk_sp<SkImage> image;
|
||||
std::shared_ptr<DlSurfaceInstance> offscreen_instance;
|
||||
sk_sp<SkSurface> offscreen;
|
||||
SkBitmap bitmap;
|
||||
|
||||
@@ -965,7 +956,9 @@ void BM_DrawImage(benchmark::State& state,
|
||||
bitmap.allocPixels(info, 0);
|
||||
bitmap.eraseColor(SK_ColorBLUE);
|
||||
} else {
|
||||
offscreen = canvas_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen_instance =
|
||||
surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen = offscreen_instance->sk_surface();
|
||||
offscreen->getCanvas()->clear(SK_ColorRED);
|
||||
}
|
||||
|
||||
@@ -991,13 +984,13 @@ void BM_DrawImage(benchmark::State& state,
|
||||
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawImage-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawImage-" +
|
||||
(upload_bitmap ? "Upload-" : "Texture-") +
|
||||
std::to_string(bitmap_size) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
std::string ConstraintToString(SkCanvas::SrcRectConstraint constraint) {
|
||||
@@ -1021,7 +1014,7 @@ void BM_DrawImageRect(benchmark::State& state,
|
||||
DlImageSampling options,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(
|
||||
GetPaintForRun(attributes),
|
||||
@@ -1031,10 +1024,12 @@ void BM_DrawImageRect(benchmark::State& state,
|
||||
|
||||
size_t bitmap_size = state.range(0);
|
||||
size_t canvas_size = 2 * bitmap_size;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
sk_sp<SkImage> image;
|
||||
std::shared_ptr<DlSurfaceInstance> offscreen_instance;
|
||||
sk_sp<SkSurface> offscreen;
|
||||
SkBitmap bitmap;
|
||||
|
||||
@@ -1045,7 +1040,9 @@ void BM_DrawImageRect(benchmark::State& state,
|
||||
bitmap.allocPixels(info, 0);
|
||||
bitmap.eraseColor(SK_ColorBLUE);
|
||||
} else {
|
||||
offscreen = canvas_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen_instance =
|
||||
surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen = offscreen_instance->sk_surface();
|
||||
offscreen->getCanvas()->clear(SK_ColorRED);
|
||||
}
|
||||
|
||||
@@ -1074,14 +1071,14 @@ void BM_DrawImageRect(benchmark::State& state,
|
||||
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawImageRect-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawImageRect-" +
|
||||
(upload_bitmap ? "Upload-" : "Texture-") +
|
||||
ConstraintToString(constraint) + "-" +
|
||||
std::to_string(bitmap_size) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
std::string FilterModeToString(const DlFilterMode mode) {
|
||||
@@ -1105,7 +1102,7 @@ void BM_DrawImageNine(benchmark::State& state,
|
||||
unsigned attributes,
|
||||
const DlFilterMode filter,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(
|
||||
GetPaintForRun(attributes),
|
||||
@@ -1115,13 +1112,15 @@ void BM_DrawImageNine(benchmark::State& state,
|
||||
|
||||
size_t bitmap_size = state.range(0);
|
||||
size_t canvas_size = 2 * bitmap_size;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkIRect center = SkIRect::MakeXYWH(bitmap_size / 4, bitmap_size / 4,
|
||||
bitmap_size / 2, bitmap_size / 2);
|
||||
|
||||
sk_sp<SkImage> image;
|
||||
std::shared_ptr<DlSurfaceInstance> offscreen_instance;
|
||||
sk_sp<SkSurface> offscreen;
|
||||
SkBitmap bitmap;
|
||||
|
||||
@@ -1132,7 +1131,9 @@ void BM_DrawImageNine(benchmark::State& state,
|
||||
bitmap.allocPixels(info, 0);
|
||||
bitmap.eraseColor(SK_ColorBLUE);
|
||||
} else {
|
||||
offscreen = canvas_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen_instance =
|
||||
surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
|
||||
offscreen = offscreen_instance->sk_surface();
|
||||
offscreen->getCanvas()->clear(SK_ColorRED);
|
||||
}
|
||||
|
||||
@@ -1158,14 +1159,14 @@ void BM_DrawImageNine(benchmark::State& state,
|
||||
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawImageNine-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawImageNine-" +
|
||||
(upload_bitmap ? "Upload-" : "Texture-") +
|
||||
FilterModeToString(filter) + "-" +
|
||||
std::to_string(bitmap_size) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draws a series of glyph runs with 32 glyphs in each run. The number of runs
|
||||
@@ -1178,7 +1179,7 @@ void BM_DrawImageNine(benchmark::State& state,
|
||||
void BM_DrawTextBlob(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawTextBlobFlags);
|
||||
@@ -1186,8 +1187,9 @@ void BM_DrawTextBlob(benchmark::State& state,
|
||||
|
||||
size_t draw_calls = state.range(0);
|
||||
size_t canvas_size = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(canvas_size, canvas_size);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
state.counters["DrawCallCount_Varies"] = draw_calls;
|
||||
state.counters["GlyphCount"] = draw_calls;
|
||||
@@ -1203,12 +1205,12 @@ void BM_DrawTextBlob(benchmark::State& state,
|
||||
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawTextBlob-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawTextBlob-" +
|
||||
std::to_string(draw_calls) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Draw the shadow for a 10-sided regular polygon where the polygon's
|
||||
@@ -1224,15 +1226,16 @@ void BM_DrawShadow(benchmark::State& state,
|
||||
unsigned attributes,
|
||||
bool transparent_occluder,
|
||||
SkPath::Verb type) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kDrawShadowFlags);
|
||||
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawShadowFlags);
|
||||
|
||||
size_t length = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
SkPath path;
|
||||
|
||||
@@ -1267,14 +1270,14 @@ void BM_DrawShadow(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-DrawShadow-" +
|
||||
auto filename = surface_provider->backend_name() + "-DrawShadow-" +
|
||||
VerbToString(type) + "-" +
|
||||
(transparent_occluder ? "Transparent-" : "Opaque-") +
|
||||
std::to_string(elevation) + "-" + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
// Calls saveLayer N times from the root canvas layer, and optionally calls
|
||||
@@ -1287,15 +1290,16 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
size_t save_depth) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
auto surface_provider = DlSurfaceProvider::Create(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
builder.setAttributesFromPaint(GetPaintForRun(attributes),
|
||||
DisplayListOpFlags::kSaveLayerFlags);
|
||||
AnnotateAttributes(attributes, state, DisplayListOpFlags::kSaveLayerFlags);
|
||||
|
||||
size_t length = kFixedCanvasSize;
|
||||
canvas_provider->InitializeSurface(length, length);
|
||||
auto canvas = canvas_provider->GetSurface()->getCanvas();
|
||||
surface_provider->InitializeSurface(length, length);
|
||||
auto surface = surface_provider->GetPrimarySurface()->sk_surface();
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
size_t save_layer_calls = state.range(0);
|
||||
|
||||
@@ -1320,14 +1324,26 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
// We only want to time the actual rasterization.
|
||||
for ([[maybe_unused]] auto _ : state) {
|
||||
display_list->RenderTo(canvas);
|
||||
canvas_provider->GetSurface()->flushAndSubmit(true);
|
||||
surface->flushAndSubmit(true);
|
||||
}
|
||||
|
||||
auto filename = canvas_provider->BackendName() + "-SaveLayer-" +
|
||||
auto filename = surface_provider->backend_name() + "-SaveLayer-" +
|
||||
std::to_string(save_depth) + "-" +
|
||||
std::to_string(save_layer_calls) + ".png";
|
||||
canvas_provider->Snapshot(filename);
|
||||
surface_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SOFTWARE_BENCHMARKS
|
||||
RUN_DISPLAYLIST_BENCHMARKS(Software)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL_BENCHMARKS
|
||||
RUN_DISPLAYLIST_BENCHMARKS(OpenGL)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL_BENCHMARKS
|
||||
RUN_DISPLAYLIST_BENCHMARKS(Metal)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#ifndef FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_H_
|
||||
|
||||
#include "flutter/display_list/display_list_benchmarks_canvas_provider.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_vertices.h"
|
||||
#include "flutter/display_list/testing/dl_test_surface_provider.h"
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
@@ -16,21 +16,9 @@
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/core/SkVertices.h"
|
||||
|
||||
#ifdef ENABLE_SOFTWARE_BENCHMARKS
|
||||
#include "flutter/display_list/display_list_benchmarks_software.h"
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL_BENCHMARKS
|
||||
#include "flutter/display_list/display_list_benchmarks_gl.h"
|
||||
#endif
|
||||
#ifdef ENABLE_METAL_BENCHMARKS
|
||||
#include "flutter/display_list/display_list_benchmarks_metal.h"
|
||||
#endif
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
typedef enum { kSoftware_Backend, kOpenGL_Backend, kMetal_Backend } BackendType;
|
||||
|
||||
enum BenchmarkAttributes {
|
||||
kEmpty_Flag = 0,
|
||||
kStrokedStyle_Flag = 1 << 0,
|
||||
@@ -39,9 +27,10 @@ enum BenchmarkAttributes {
|
||||
kAntiAliasing_Flag = 1 << 3
|
||||
};
|
||||
|
||||
std::unique_ptr<CanvasProvider> CreateCanvasProvider(BackendType backend_type);
|
||||
SkPaint GetPaintForRun(unsigned attributes);
|
||||
|
||||
using BackendType = DlSurfaceProvider::BackendType;
|
||||
|
||||
// Benchmarks
|
||||
|
||||
void BM_DrawLine(benchmark::State& state,
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// 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_FLOW_DISPLAY_LIST_BENCHMARKS_CANVAS_PROVIDER_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_CANVAS_PROVIDER_H_
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkData.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class CanvasProvider {
|
||||
public:
|
||||
virtual ~CanvasProvider() = default;
|
||||
virtual const std::string BackendName() = 0;
|
||||
virtual void InitializeSurface(const size_t width, const size_t height) = 0;
|
||||
virtual sk_sp<SkSurface> GetSurface() = 0;
|
||||
virtual sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
|
||||
const size_t height) = 0;
|
||||
|
||||
virtual bool Snapshot(std::string filename) {
|
||||
#ifdef BENCHMARKS_NO_SNAPSHOT
|
||||
return false;
|
||||
#else
|
||||
auto image = GetSurface()->makeImageSnapshot();
|
||||
if (!image) {
|
||||
return false;
|
||||
}
|
||||
auto raster = image->makeRasterImage();
|
||||
if (!raster) {
|
||||
return false;
|
||||
}
|
||||
auto data = raster->encodeToData();
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
fml::NonOwnedMapping mapping(static_cast<const uint8_t*>(data->data()),
|
||||
data->size());
|
||||
return WriteAtomically(OpenFixturesDirectory(), filename.c_str(), mapping);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_CANVAS_PROVIDER_H_
|
||||
@@ -1,52 +0,0 @@
|
||||
// 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/display_list/display_list_benchmarks_gl.h"
|
||||
#include "flutter/display_list/display_list_benchmarks.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
void OpenGLCanvasProvider::InitializeSurface(const size_t width,
|
||||
const size_t height) {
|
||||
surface_size_ = SkISize::Make(width, height);
|
||||
|
||||
gl_surface_ = std::make_unique<TestGLSurface>(surface_size_);
|
||||
gl_surface_->MakeCurrent();
|
||||
|
||||
const auto image_info = SkImageInfo::MakeN32Premul(surface_size_);
|
||||
surface_ = SkSurface::MakeRenderTarget(
|
||||
gl_surface_->GetGrContext().get(), skgpu::Budgeted::kNo, image_info, 1,
|
||||
kTopLeft_GrSurfaceOrigin, nullptr, false);
|
||||
surface_->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> OpenGLCanvasProvider::GetSurface() {
|
||||
if (!gl_surface_->MakeCurrent()) {
|
||||
return nullptr;
|
||||
}
|
||||
return surface_;
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> OpenGLCanvasProvider::MakeOffscreenSurface(
|
||||
const size_t width,
|
||||
const size_t height) {
|
||||
surface_size_ = SkISize::Make(width, height);
|
||||
const auto image_info = SkImageInfo::MakeN32Premul(surface_size_);
|
||||
|
||||
auto offscreen_surface = SkSurface::MakeRenderTarget(
|
||||
gl_surface_->GetGrContext().get(), skgpu::Budgeted::kNo, image_info, 1,
|
||||
kTopLeft_GrSurfaceOrigin, nullptr, false);
|
||||
|
||||
offscreen_surface->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
return offscreen_surface;
|
||||
}
|
||||
|
||||
RUN_DISPLAYLIST_BENCHMARKS(OpenGL)
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -1,35 +0,0 @@
|
||||
// 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_FLOW_DISPLAY_LIST_BENCHMARKS_GL_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_GL_H_
|
||||
|
||||
#include "flutter/display_list/display_list_benchmarks_canvas_provider.h"
|
||||
|
||||
#include "flutter/testing/test_gl_surface.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class OpenGLCanvasProvider : public CanvasProvider {
|
||||
public:
|
||||
virtual ~OpenGLCanvasProvider() = default;
|
||||
void InitializeSurface(const size_t width, const size_t height) override;
|
||||
sk_sp<SkSurface> GetSurface() override;
|
||||
sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
|
||||
const size_t height) override;
|
||||
const std::string BackendName() override { return "OpenGL"; }
|
||||
|
||||
private:
|
||||
SkISize surface_size_;
|
||||
sk_sp<SkSurface> surface_;
|
||||
std::unique_ptr<TestGLSurface> gl_surface_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_GL_H_
|
||||
@@ -1,40 +0,0 @@
|
||||
// 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/display_list/display_list_benchmarks_metal.h"
|
||||
#include "flutter/display_list/display_list_benchmarks.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
void MetalCanvasProvider::InitializeSurface(const size_t width,
|
||||
const size_t height) {
|
||||
metal_context_ = std::make_unique<TestMetalContext>();
|
||||
metal_surface_ =
|
||||
TestMetalSurface::Create(*metal_context_, SkISize::Make(width, height));
|
||||
metal_surface_->GetSurface()->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> MetalCanvasProvider::GetSurface() {
|
||||
if (!metal_surface_) {
|
||||
return nullptr;
|
||||
}
|
||||
return metal_surface_->GetSurface();
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> MetalCanvasProvider::MakeOffscreenSurface(
|
||||
const size_t width,
|
||||
const size_t height) {
|
||||
metal_offscreen_surface_ =
|
||||
TestMetalSurface::Create(*metal_context_, SkISize::Make(width, height));
|
||||
return metal_offscreen_surface_->GetSurface();
|
||||
}
|
||||
|
||||
RUN_DISPLAYLIST_BENCHMARKS(Metal)
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -1,35 +0,0 @@
|
||||
// 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_FLOW_DISPLAY_LIST_BENCHMARKS_METAL_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_METAL_H_
|
||||
|
||||
#include "flutter/display_list/display_list_benchmarks_canvas_provider.h"
|
||||
#include "flutter/testing/test_metal_surface.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class MetalCanvasProvider : public CanvasProvider {
|
||||
public:
|
||||
virtual ~MetalCanvasProvider() = default;
|
||||
|
||||
void InitializeSurface(const size_t width, const size_t height) override;
|
||||
sk_sp<SkSurface> GetSurface() override;
|
||||
sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
|
||||
const size_t height) override;
|
||||
const std::string BackendName() override { return "Metal"; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<TestMetalContext> metal_context_;
|
||||
std::unique_ptr<TestMetalSurface> metal_surface_;
|
||||
std::unique_ptr<TestMetalSurface> metal_offscreen_surface_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_METAL_H_
|
||||
@@ -1,30 +0,0 @@
|
||||
// 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/display_list/display_list_benchmarks_software.h"
|
||||
#include "flutter/display_list/display_list_benchmarks.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
void SoftwareCanvasProvider::InitializeSurface(const size_t width,
|
||||
const size_t height) {
|
||||
surface_ = SkSurface::MakeRasterN32Premul(width, height);
|
||||
surface_->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> SoftwareCanvasProvider::MakeOffscreenSurface(
|
||||
const size_t width,
|
||||
const size_t height) {
|
||||
auto surface = SkSurface::MakeRasterN32Premul(width, height);
|
||||
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
return surface;
|
||||
}
|
||||
|
||||
RUN_DISPLAYLIST_BENCHMARKS(Software)
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -1,31 +0,0 @@
|
||||
// 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_FLOW_DISPLAY_LIST_BENCHMARKS_SOFTWARE_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_SOFTWARE_H_
|
||||
|
||||
#include "flutter/display_list/display_list_benchmarks_canvas_provider.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class SoftwareCanvasProvider : public CanvasProvider {
|
||||
public:
|
||||
virtual ~SoftwareCanvasProvider() = default;
|
||||
void InitializeSurface(const size_t width, const size_t height) override;
|
||||
sk_sp<SkSurface> GetSurface() override { return surface_; }
|
||||
sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
|
||||
const size_t height) override;
|
||||
const std::string BackendName() override { return "Software"; }
|
||||
|
||||
private:
|
||||
sk_sp<SkSurface> surface_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_SOFTWARE_H_
|
||||
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/benchmarking/benchmarking.h"
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/display_list/testing/dl_test_snippets.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_color_filter.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_color_source.h"
|
||||
#include "flutter/display_list/display_list_image.h"
|
||||
#include "flutter/display_list/display_list_runtime_effect.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "third_party/skia/include/core/SkString.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_color_source.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "flutter/display_list/display_list_complexity_gl.h"
|
||||
#include "flutter/display_list/display_list_complexity_metal.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/display_list/testing/dl_test_snippets.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_blend_mode.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_color.h"
|
||||
@@ -11,6 +10,7 @@
|
||||
#include "flutter/display_list/display_list_image_filter.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_tile_mode.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/display_list_mask_filter.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "include/core/SkPath.h"
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "flutter/display_list/display_list_canvas_recorder.h"
|
||||
#include "flutter/display_list/display_list_paint.h"
|
||||
#include "flutter/display_list/display_list_rtree.h"
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/display_list/display_list_utils.h"
|
||||
#include "flutter/display_list/testing/dl_test_snippets.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/math.h"
|
||||
#include "flutter/testing/display_list_testing.h"
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/display_list_vertices.h"
|
||||
#include "flutter/display_list/testing/dl_test_equality.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
104
engine/src/flutter/display_list/testing/BUILD.gn
Normal file
104
engine/src/flutter/display_list/testing/BUILD.gn
Normal file
@@ -0,0 +1,104 @@
|
||||
# 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.
|
||||
# We only do software benchmarks on non-mobile platforms
|
||||
|
||||
import("//flutter/impeller/tools/impeller.gni")
|
||||
|
||||
source_set("display_list_testing") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"dl_test_equality.h",
|
||||
"dl_test_snippets.cc",
|
||||
"dl_test_snippets.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//flutter/testing:testing_lib",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
public_deps = [ "//flutter/display_list:display_list" ]
|
||||
}
|
||||
|
||||
surface_provider_include_software = !is_android && !is_ios
|
||||
|
||||
# iOS and Fuchsia and Windows don't support OpenGL
|
||||
# Note: Windows would need some work to support OpenGL
|
||||
# But, since benchmarks do not run on Windows and rendertests only
|
||||
# runs on SW by default, this restriction currently only limits the
|
||||
# ability to manually cross-check OpenGL on Windows for rendertests
|
||||
surface_provider_include_gl = !is_fuchsia && !is_ios && !is_win
|
||||
|
||||
# TODO (https://github.com/flutter/flutter/issues/107357):
|
||||
# impeller_enable_vulkan currently requires skia to not use VMA, which in turn
|
||||
# causes linkage problems with swiftshader.
|
||||
if (impeller_enable_vulkan) {
|
||||
surface_provider_include_gl = false
|
||||
}
|
||||
|
||||
surface_provider_include_metal = is_mac || is_ios
|
||||
|
||||
config("surface_provider_config") {
|
||||
defines = []
|
||||
|
||||
if (surface_provider_include_software) {
|
||||
defines += [ "ENABLE_SOFTWARE_BENCHMARKS" ]
|
||||
}
|
||||
if (surface_provider_include_gl) {
|
||||
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
|
||||
}
|
||||
if (surface_provider_include_metal) {
|
||||
defines += [ "ENABLE_METAL_BENCHMARKS" ]
|
||||
}
|
||||
|
||||
# Don't snapshot test results on mobile platforms
|
||||
if (is_android || is_ios) {
|
||||
defines += [ "BENCHMARKS_NO_SNAPSHOT" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("display_list_surface_provider") {
|
||||
testonly = true
|
||||
|
||||
sources = [ "dl_test_surface_provider.cc" ]
|
||||
|
||||
deps = [
|
||||
"//flutter/common/graphics",
|
||||
"//flutter/testing:testing_lib",
|
||||
]
|
||||
|
||||
public_configs = [ ":surface_provider_config" ]
|
||||
|
||||
if (is_android) {
|
||||
libs = [
|
||||
"android",
|
||||
"EGL",
|
||||
"GLESv2",
|
||||
]
|
||||
}
|
||||
|
||||
if (surface_provider_include_software) {
|
||||
sources += [
|
||||
"dl_test_surface_software.cc",
|
||||
"dl_test_surface_software.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (surface_provider_include_gl) {
|
||||
sources += [
|
||||
"dl_test_surface_gl.cc",
|
||||
"dl_test_surface_gl.h",
|
||||
]
|
||||
deps += [ "//flutter/testing:opengl" ]
|
||||
}
|
||||
|
||||
if (surface_provider_include_metal) {
|
||||
sources += [
|
||||
"dl_test_surface_metal.cc",
|
||||
"dl_test_surface_metal.h",
|
||||
]
|
||||
deps += [ "//flutter/testing:metal" ]
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_DISPLAY_LIST_DISPLAY_LIST_ATTRIBUTES_TESTING_H_
|
||||
#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_ATTRIBUTES_TESTING_H_
|
||||
#ifndef FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_EQUALITY_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_EQUALITY_H_
|
||||
|
||||
#include "flutter/display_list/display_list_attributes.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
@@ -39,4 +39,4 @@ static void TestNotEquals(T& source1, T& source2, std::string label) {
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_DISPLAY_LIST_ATTRIBUTES_TESTING_H_
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_EQUALITY_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/display_list/testing/dl_test_snippets.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
|
||||
namespace flutter {
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_UNITTESTS_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_UNITTESTS_H_
|
||||
#ifndef FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SNIPPETS_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SNIPPETS_H_
|
||||
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
@@ -333,4 +333,4 @@ std::vector<DisplayListInvocationGroup> CreateAllGroups();
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_UNITTESTS_H_
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SNIPPETS_H_
|
||||
@@ -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/display_list/testing/dl_test_surface_gl.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
using PixelFormat = DlSurfaceProvider::PixelFormat;
|
||||
|
||||
bool DlOpenGLSurfaceProvider::InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) {
|
||||
gl_surface_ = std::make_unique<TestGLSurface>(SkISize::Make(width, height));
|
||||
gl_surface_->MakeCurrent();
|
||||
|
||||
primary_ = MakeOffscreenSurface(width, height, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<DlSurfaceInstance> DlOpenGLSurfaceProvider::GetPrimarySurface()
|
||||
const {
|
||||
if (!gl_surface_->MakeCurrent()) {
|
||||
return nullptr;
|
||||
}
|
||||
return primary_;
|
||||
}
|
||||
|
||||
std::shared_ptr<DlSurfaceInstance>
|
||||
DlOpenGLSurfaceProvider::MakeOffscreenSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const {
|
||||
auto offscreen_surface = SkSurface::MakeRenderTarget(
|
||||
(GrRecordingContext*)gl_surface_->GetGrContext().get(),
|
||||
skgpu::Budgeted::kNo, MakeInfo(format, width, height), 1,
|
||||
kTopLeft_GrSurfaceOrigin, nullptr, false);
|
||||
|
||||
offscreen_surface->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
return std::make_shared<DlSurfaceInstanceBase>(offscreen_surface);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
42
engine/src/flutter/display_list/testing/dl_test_surface_gl.h
Normal file
42
engine/src/flutter/display_list/testing/dl_test_surface_gl.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_GL_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_GL_H_
|
||||
|
||||
#include "flutter/display_list/testing/dl_test_surface_provider.h"
|
||||
|
||||
#include "flutter/testing/test_gl_surface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class DlOpenGLSurfaceProvider : public DlSurfaceProvider {
|
||||
public:
|
||||
DlOpenGLSurfaceProvider() : DlSurfaceProvider() {}
|
||||
virtual ~DlOpenGLSurfaceProvider() = default;
|
||||
|
||||
bool InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) override;
|
||||
std::shared_ptr<DlSurfaceInstance> GetPrimarySurface() const override;
|
||||
std::shared_ptr<DlSurfaceInstance> MakeOffscreenSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const override;
|
||||
const std::string backend_name() const override { return "OpenGL"; }
|
||||
BackendType backend_type() const override { return kOpenGL_Backend; }
|
||||
bool supports(PixelFormat format) const override {
|
||||
return format == kN32Premul_PixelFormat;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<DlSurfaceInstance> primary_;
|
||||
std::unique_ptr<TestGLSurface> gl_surface_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_GL_H_
|
||||
@@ -0,0 +1,58 @@
|
||||
// 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/display_list/testing/dl_test_surface_metal.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class DlMetalSurfaceInstance : public DlSurfaceInstance {
|
||||
public:
|
||||
explicit DlMetalSurfaceInstance(
|
||||
std::unique_ptr<TestMetalSurface> metal_surface)
|
||||
: metal_surface_(std::move(metal_surface)) {}
|
||||
~DlMetalSurfaceInstance() = default;
|
||||
|
||||
sk_sp<SkSurface> sk_surface() const override {
|
||||
return metal_surface_->GetSurface();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<TestMetalSurface> metal_surface_;
|
||||
};
|
||||
|
||||
bool DlMetalSurfaceProvider::InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) {
|
||||
if (format != kN32Premul_PixelFormat) {
|
||||
return false;
|
||||
}
|
||||
metal_context_ = std::make_unique<TestMetalContext>();
|
||||
metal_surface_ = MakeOffscreenSurface(width, height, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<DlSurfaceInstance> DlMetalSurfaceProvider::GetPrimarySurface()
|
||||
const {
|
||||
if (!metal_surface_) {
|
||||
return nullptr;
|
||||
}
|
||||
return metal_surface_;
|
||||
}
|
||||
|
||||
std::shared_ptr<DlSurfaceInstance> DlMetalSurfaceProvider::MakeOffscreenSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const {
|
||||
auto surface =
|
||||
TestMetalSurface::Create(*metal_context_, SkISize::Make(width, height));
|
||||
surface->GetSurface()->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
return std::make_shared<DlMetalSurfaceInstance>(std::move(surface));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,42 @@
|
||||
// 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_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_METAL_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_METAL_H_
|
||||
|
||||
#include "flutter/display_list/testing/dl_test_surface_provider.h"
|
||||
|
||||
#include "flutter/testing/test_metal_surface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class DlMetalSurfaceProvider : public DlSurfaceProvider {
|
||||
public:
|
||||
explicit DlMetalSurfaceProvider() : DlSurfaceProvider() {}
|
||||
virtual ~DlMetalSurfaceProvider() = default;
|
||||
|
||||
bool InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) override;
|
||||
std::shared_ptr<DlSurfaceInstance> GetPrimarySurface() const override;
|
||||
std::shared_ptr<DlSurfaceInstance> MakeOffscreenSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const override;
|
||||
const std::string backend_name() const override { return "Metal"; }
|
||||
BackendType backend_type() const override { return kMetal_Backend; }
|
||||
bool supports(PixelFormat format) const override {
|
||||
return format == kN32Premul_PixelFormat;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<TestMetalContext> metal_context_;
|
||||
std::shared_ptr<DlSurfaceInstance> metal_surface_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_METAL_H_
|
||||
@@ -0,0 +1,69 @@
|
||||
// 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/display_list/testing/dl_test_surface_provider.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkData.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
#ifdef ENABLE_SOFTWARE_BENCHMARKS
|
||||
#include "flutter/display_list/testing/dl_test_surface_software.h"
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL_BENCHMARKS
|
||||
#include "flutter/display_list/testing/dl_test_surface_gl.h"
|
||||
#endif
|
||||
#ifdef ENABLE_METAL_BENCHMARKS
|
||||
#include "flutter/display_list/testing/dl_test_surface_metal.h"
|
||||
#endif
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
std::unique_ptr<DlSurfaceProvider> DlSurfaceProvider::Create(
|
||||
BackendType backend_type) {
|
||||
switch (backend_type) {
|
||||
#ifdef ENABLE_SOFTWARE_BENCHMARKS
|
||||
case kSoftware_Backend:
|
||||
return std::make_unique<DlSoftwareSurfaceProvider>();
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL_BENCHMARKS
|
||||
case kOpenGL_Backend:
|
||||
return std::make_unique<DlOpenGLSurfaceProvider>();
|
||||
#endif
|
||||
#ifdef ENABLE_METAL_BENCHMARKS
|
||||
case kMetal_Backend:
|
||||
return std::make_unique<DlMetalSurfaceProvider>();
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DlSurfaceProvider::Snapshot(std::string& filename) const {
|
||||
#ifdef BENCHMARKS_NO_SNAPSHOT
|
||||
return false;
|
||||
#else
|
||||
auto image = GetPrimarySurface()->sk_surface()->makeImageSnapshot();
|
||||
if (!image) {
|
||||
return false;
|
||||
}
|
||||
auto raster = image->makeRasterImage();
|
||||
if (!raster) {
|
||||
return false;
|
||||
}
|
||||
auto data = raster->encodeToData();
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
fml::NonOwnedMapping mapping(static_cast<const uint8_t*>(data->data()),
|
||||
data->size());
|
||||
return WriteAtomically(OpenFixturesDirectory(), filename.c_str(), mapping);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class DlSurfaceInstance {
|
||||
public:
|
||||
virtual ~DlSurfaceInstance() = default;
|
||||
|
||||
virtual sk_sp<SkSurface> sk_surface() const = 0;
|
||||
|
||||
int width() const { return sk_surface()->width(); }
|
||||
int height() const { return sk_surface()->height(); }
|
||||
};
|
||||
|
||||
class DlSurfaceInstanceBase : public DlSurfaceInstance {
|
||||
public:
|
||||
DlSurfaceInstanceBase(sk_sp<SkSurface> surface) : surface_(surface) {}
|
||||
~DlSurfaceInstanceBase() = default;
|
||||
|
||||
sk_sp<SkSurface> sk_surface() const override { return surface_; }
|
||||
|
||||
private:
|
||||
sk_sp<SkSurface> surface_;
|
||||
};
|
||||
|
||||
class DlSurfaceProvider {
|
||||
public:
|
||||
typedef enum { kN32Premul_PixelFormat, k565_PixelFormat } PixelFormat;
|
||||
typedef enum {
|
||||
kSoftware_Backend,
|
||||
kOpenGL_Backend,
|
||||
kMetal_Backend
|
||||
} BackendType;
|
||||
|
||||
static SkImageInfo MakeInfo(PixelFormat format, int w, int h) {
|
||||
switch (format) {
|
||||
case kN32Premul_PixelFormat:
|
||||
return SkImageInfo::MakeN32Premul(w, h);
|
||||
case k565_PixelFormat:
|
||||
return SkImageInfo::Make(SkISize::Make(w, h), kRGB_565_SkColorType,
|
||||
kOpaque_SkAlphaType);
|
||||
}
|
||||
FML_DCHECK(false);
|
||||
}
|
||||
|
||||
static std::unique_ptr<DlSurfaceProvider> Create(BackendType backend_type);
|
||||
|
||||
virtual ~DlSurfaceProvider() = default;
|
||||
virtual const std::string backend_name() const = 0;
|
||||
virtual BackendType backend_type() const = 0;
|
||||
virtual bool supports(PixelFormat format) const = 0;
|
||||
virtual bool InitializeSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format = kN32Premul_PixelFormat) = 0;
|
||||
virtual std::shared_ptr<DlSurfaceInstance> GetPrimarySurface() const = 0;
|
||||
virtual std::shared_ptr<DlSurfaceInstance> MakeOffscreenSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format = kN32Premul_PixelFormat) const = 0;
|
||||
|
||||
virtual bool Snapshot(std::string& filename) const;
|
||||
|
||||
protected:
|
||||
DlSurfaceProvider() = default;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_PROVIDER_H_
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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/display_list/testing/dl_test_surface_software.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
using PixelFormat = DlSurfaceProvider::PixelFormat;
|
||||
|
||||
bool DlSoftwareSurfaceProvider::InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) {
|
||||
primary_ = MakeOffscreenSurface(width, height, format);
|
||||
return primary_ != nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<DlSurfaceInstance>
|
||||
DlSoftwareSurfaceProvider::MakeOffscreenSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const {
|
||||
auto surface = SkSurface::MakeRaster(MakeInfo(format, width, height));
|
||||
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
return std::make_shared<DlSurfaceInstanceBase>(surface);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_SOFTWARE_H_
|
||||
#define FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_SOFTWARE_H_
|
||||
|
||||
#include "flutter/display_list/testing/dl_test_surface_provider.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class DlSoftwareSurfaceProvider : public DlSurfaceProvider {
|
||||
public:
|
||||
DlSoftwareSurfaceProvider() = default;
|
||||
virtual ~DlSoftwareSurfaceProvider() = default;
|
||||
|
||||
bool InitializeSurface(size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) override;
|
||||
std::shared_ptr<DlSurfaceInstance> GetPrimarySurface() const override {
|
||||
return primary_;
|
||||
}
|
||||
std::shared_ptr<DlSurfaceInstance> MakeOffscreenSurface(
|
||||
size_t width,
|
||||
size_t height,
|
||||
PixelFormat format) const override;
|
||||
const std::string backend_name() const override { return "Software"; }
|
||||
BackendType backend_type() const override { return kSoftware_Backend; }
|
||||
bool supports(PixelFormat format) const override { return true; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<DlSurfaceInstance> primary_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_TESTING_DL_TEST_SURFACE_SOFTWARE_H_
|
||||
@@ -183,7 +183,7 @@ if (enable_unittests) {
|
||||
":flow_fixtures",
|
||||
":flow_testing",
|
||||
"//flutter/common/graphics",
|
||||
"//flutter/display_list:display_list_testing",
|
||||
"//flutter/display_list/testing:display_list_testing",
|
||||
"//flutter/fml",
|
||||
"//flutter/testing:skia",
|
||||
"//flutter/testing:testing_lib",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/display_list/testing/dl_test_snippets.h"
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/layers/display_list_layer.h"
|
||||
#include "flutter/flow/layers/image_filter_layer.h"
|
||||
|
||||
Reference in New Issue
Block a user