Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6f99a71

Browse files
author
George Wright
authored
Enable DisplayList benchmarks to be built on Android (#31268)
1 parent c490e48 commit 6f99a71

File tree

3 files changed

+90
-78
lines changed

3 files changed

+90
-78
lines changed

benchmarking/benchmarking.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
#include "benchmarking.h"
66

77
#include "flutter/fml/backtrace.h"
8+
#include "flutter/fml/build_config.h"
89
#include "flutter/fml/command_line.h"
910
#include "flutter/fml/icu_util.h"
1011

1112
namespace benchmarking {
1213

1314
int Main(int argc, char** argv) {
1415
fml::InstallCrashHandler();
16+
#if !defined(FML_OS_ANDROID)
1517
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);
16-
benchmark::Initialize(&argc, argv);
1718
std::string icudtl_path =
1819
cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat");
1920
fml::icu::InitializeICU(icudtl_path);
21+
#endif
22+
benchmark::Initialize(&argc, argv);
2023
::benchmark::RunSpecifiedBenchmarks();
2124
return 0;
2225
}

display_list/BUILD.gn

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -55,51 +55,76 @@ fixtures_location("display_list_benchmarks_fixtures") {
5555
assets_dir = "$target_gen_dir/"
5656
}
5757

58-
if (enable_unittests) {
59-
executable("display_list_benchmarks") {
60-
testonly = true
58+
source_set("display_list_benchmarks_source") {
59+
testonly = true
60+
61+
sources = [
62+
"display_list_benchmarks.cc",
63+
"display_list_benchmarks.h",
64+
]
65+
66+
deps = [
67+
":display_list",
68+
":display_list_benchmarks_fixtures",
69+
"//flutter/benchmarking",
70+
"//flutter/common/graphics",
71+
"//flutter/fml",
72+
"//flutter/testing:skia",
73+
"//flutter/testing:testing_lib",
74+
"//third_party/dart/runtime:libdart_jit", # for tracing
75+
"//third_party/skia",
76+
]
77+
78+
defines = []
6179

62-
sources = [
63-
"display_list_benchmarks.cc",
64-
"display_list_benchmarks.h",
80+
if (is_android) {
81+
libs = [
82+
"android",
83+
"EGL",
84+
"GLESv2",
85+
]
86+
}
87+
88+
# We only do software benchmarks on non-mobile platforms
89+
if (!is_android && !is_ios) {
90+
sources += [
6591
"display_list_benchmarks_software.cc",
6692
"display_list_benchmarks_software.h",
6793
]
94+
defines += [ "ENABLE_SOFTWARE_BENCHMARKS" ]
95+
}
96+
97+
# iOS and Fuchsia don't support OpenGL
98+
if (!is_fuchsia && !is_ios) {
99+
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
100+
sources += [
101+
"display_list_benchmarks_gl.cc",
102+
"display_list_benchmarks_gl.h",
103+
]
104+
deps += [ "//flutter/testing:opengl" ]
105+
}
68106

69-
deps = [
70-
":display_list",
71-
":display_list_benchmarks_fixtures",
72-
"//flutter/benchmarking",
73-
"//flutter/common/graphics",
74-
"//flutter/fml",
75-
"//flutter/testing:skia",
76-
"//flutter/testing:testing_lib",
77-
"//third_party/dart/runtime:libdart_jit", # for tracing
78-
"//third_party/skia",
107+
if (is_mac || is_ios) {
108+
defines += [ "ENABLE_METAL_BENCHMARKS" ]
109+
sources += [
110+
"display_list_benchmarks_metal.cc",
111+
"display_list_benchmarks_metal.h",
79112
]
113+
deps += [ "//flutter/testing:metal" ]
114+
}
80115

81-
defines = [ "ENABLE_SOFTWARE_BENCHMARKS" ]
82-
83-
if (!is_fuchsia) {
84-
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
85-
sources += [
86-
"display_list_benchmarks_gl.cc",
87-
"display_list_benchmarks_gl.h",
88-
]
89-
deps += [ "//flutter/testing:opengl" ]
90-
}
91-
92-
if (is_mac) {
93-
defines += [ "ENABLE_METAL_BENCHMARKS" ]
94-
sources += [
95-
"display_list_benchmarks_metal.cc",
96-
"display_list_benchmarks_metal.h",
97-
]
98-
deps += [ "//flutter/testing:metal" ]
99-
}
116+
# Don't snapshot test results on mobile platforms
117+
if (is_android || is_ios) {
118+
defines += [ "BENCHMARKS_NO_SNAPSHOT" ]
100119
}
101120
}
102121

122+
executable("display_list_benchmarks") {
123+
testonly = true
124+
125+
deps = [ ":display_list_benchmarks_source" ]
126+
}
127+
103128
if (is_ios) {
104129
shared_library("ios_display_list_benchmarks") {
105130
testonly = true
@@ -116,29 +141,9 @@ if (is_ios) {
116141
]
117142
ldflags =
118143
[ "-Wl,-install_name,@rpath/libios_display_list_benchmarks.dylib" ]
119-
defines = [
120-
"BENCHMARKS_NO_SNAPSHOT",
121-
"ENABLE_METAL_BENCHMARKS",
122-
]
123-
sources = [
124-
"display_list_benchmarks.cc",
125-
"display_list_benchmarks.h",
126-
"display_list_benchmarks_metal.cc",
127-
"display_list_benchmarks_metal.h",
128-
]
129-
130144
deps = [
131-
":display_list",
132-
":display_list_benchmarks_fixtures",
145+
":display_list_benchmarks_source",
133146
"//flutter/benchmarking:benchmarking_library",
134-
"//flutter/common/graphics",
135-
"//flutter/fml",
136-
"//flutter/testing:metal",
137-
"//flutter/testing:skia",
138-
"//flutter/testing:testing_lib",
139-
"//third_party/benchmark",
140-
"//third_party/dart/runtime:libdart_jit", # for tracing
141-
"//third_party/skia",
142147
]
143148
}
144149
}

testing/BUILD.gn

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,6 @@ if (enable_unittests) {
150150
}
151151
}
152152

153-
# SwiftShader only supports x86/x86_64
154-
if (target_cpu == "x86" || target_cpu == "x64") {
155-
source_set("opengl") {
156-
testonly = true
157-
158-
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
159-
160-
sources = [
161-
"test_gl_surface.cc",
162-
"test_gl_surface.h",
163-
]
164-
165-
deps = [
166-
":skia",
167-
"//flutter/fml",
168-
"//third_party/swiftshader_flutter:swiftshader_gl",
169-
]
170-
}
171-
}
172-
173153
test_fixtures("testing_fixtures") {
174154
fixtures = []
175155
}
@@ -205,7 +185,7 @@ if (enable_unittests) {
205185
# is exercised on platforms where Metal itself is available.
206186
#
207187
# On iOS, this is enabled to allow for Metal tests to run within a test app
208-
if (enable_unittests || is_ios) {
188+
if (is_mac || is_ios) {
209189
source_set("metal") {
210190
if (shell_enable_metal) {
211191
sources = [
@@ -231,3 +211,27 @@ if (enable_unittests || is_ios) {
231211
testonly = true
232212
}
233213
}
214+
215+
# We only use SwiftShader on unittests and
216+
# SwiftShader only supports x86/x86_64
217+
use_swiftshader =
218+
enable_unittests && (target_cpu == "x86" || target_cpu == "x64")
219+
220+
source_set("opengl") {
221+
testonly = true
222+
223+
sources = [
224+
"test_gl_surface.cc",
225+
"test_gl_surface.h",
226+
]
227+
228+
deps = [
229+
":skia",
230+
"//flutter/fml",
231+
]
232+
233+
if (use_swiftshader) {
234+
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
235+
deps += [ "//third_party/swiftshader_flutter:swiftshader_gl" ]
236+
}
237+
}

0 commit comments

Comments
 (0)