Skip to content

Commit

Permalink
Enable DisplayList benchmarks to be built on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
George Wright committed Feb 5, 2022
1 parent f04ac2a commit 30dacc6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
5 changes: 4 additions & 1 deletion benchmarking/benchmarking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
#include "benchmarking.h"

#include "flutter/fml/backtrace.h"
#include "flutter/fml/build_config.h"
#include "flutter/fml/command_line.h"
#include "flutter/fml/icu_util.h"

namespace benchmarking {

int Main(int argc, char** argv) {
fml::InstallCrashHandler();
#if !defined(FML_OS_ANDROID)
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);
benchmark::Initialize(&argc, argv);
std::string icudtl_path =
cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat");
fml::icu::InitializeICU(icudtl_path);
#endif
benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
return 0;
}
Expand Down
21 changes: 17 additions & 4 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ fixtures_location("display_list_benchmarks_fixtures") {
assets_dir = "$target_gen_dir/"
}

if (enable_unittests) {
if (enable_unittests || is_android) {
executable("display_list_benchmarks") {
testonly = true

sources = [
"display_list_benchmarks.cc",
"display_list_benchmarks.h",
"display_list_benchmarks_software.cc",
"display_list_benchmarks_software.h",
]

deps = [
Expand All @@ -78,7 +76,22 @@ if (enable_unittests) {
"//third_party/skia",
]

defines = [ "ENABLE_SOFTWARE_BENCHMARKS" ]
defines = []

if (is_android) {
libs = [
"android",
"EGL",
"GLESv2",
]
} else {
# We only do software benchmarks on non-mobile platforms
sources += [
"display_list_benchmarks_software.cc",
"display_list_benchmarks_software.h",
]
defines += [ "ENABLE_SOFTWARE_BENCHMARKS" ]
}

if (!is_fuchsia) {
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
Expand Down
47 changes: 27 additions & 20 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,6 @@ if (enable_unittests) {
}
}

# SwiftShader only supports x86/x86_64
if (target_cpu == "x86" || target_cpu == "x64") {
source_set("opengl") {
testonly = true

configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]

sources = [
"test_gl_surface.cc",
"test_gl_surface.h",
]

deps = [
":skia",
"//flutter/fml",
"//third_party/swiftshader_flutter:swiftshader_gl",
]
}
}

test_fixtures("testing_fixtures") {
fixtures = []
}
Expand Down Expand Up @@ -231,3 +211,30 @@ if (enable_unittests || is_ios) {
testonly = true
}
}

# We only use SwiftShader on unittests and
# SwiftShader only supports x86/x86_64
if (enable_unittests && (target_cpu == "x86" || target_cpu == "x64")) {
use_swiftshader = true
} else {
use_swiftshader = false
}

source_set("opengl") {
testonly = true

sources = [
"test_gl_surface.cc",
"test_gl_surface.h",
]

deps = [
":skia",
"//flutter/fml",
]

if (use_swiftshader) {
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps += [ "//third_party/swiftshader_flutter:swiftshader_gl" ]
}
}

0 comments on commit 30dacc6

Please sign in to comment.