From a4895a7315d3efc8b23e1ce28064fa0e5292421e Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 12 May 2022 12:49:04 -0700 Subject: [PATCH] compile a flutter tester with SUPPORT_FRACTIONAL_TRANSLATION and raster cache disabled (flutter/engine#33272) --- engine/src/flutter/BUILD.gn | 1 + engine/src/flutter/build/archives/BUILD.gn | 1 + engine/src/flutter/shell/testing/BUILD.gn | 41 +++++++++++++++++++ .../src/flutter/shell/testing/tester_main.cc | 14 ++++++- engine/src/flutter/testing/run_tests.py | 11 +++-- 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index edbbbcd20a6..b886a9729f2 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -101,6 +101,7 @@ group("flutter") { if (build_engine_artifacts) { public_deps += [ "//flutter/shell/testing", + "//flutter/shell/testing:testing_fractional_translation", "//flutter/tools/const_finder", "//flutter/tools/font-subset", ] diff --git a/engine/src/flutter/build/archives/BUILD.gn b/engine/src/flutter/build/archives/BUILD.gn index 2bfa95ed095..a076000a238 100644 --- a/engine/src/flutter/build/archives/BUILD.gn +++ b/engine/src/flutter/build/archives/BUILD.gn @@ -13,6 +13,7 @@ if (build_engine_artifacts) { "//flutter/impeller/tessellator:tessellator_shared", "//flutter/lib/snapshot:generate_snapshot_bin", "//flutter/shell/testing:testing", + "//flutter/shell/testing:testing_fractional_translation", ] prefix = "$full_target_platform_name/" if (flutter_runtime_mode != "debug") { diff --git a/engine/src/flutter/shell/testing/BUILD.gn b/engine/src/flutter/shell/testing/BUILD.gn index 247b168bae9..73f888865df 100644 --- a/engine/src/flutter/shell/testing/BUILD.gn +++ b/engine/src/flutter/shell/testing/BUILD.gn @@ -36,3 +36,44 @@ executable("testing") { "//third_party/skia", ] } + +# A second tester binary with SUPPORT_FRACTIONAL_TRANSLATION enabled +# and the raster cache disabled. +executable("testing_fractional_translation") { + output_name = "flutter_tester_fractional_translation" + + public_configs = [ + "//flutter:config", + "//flutter:export_dynamic_symbols", + ] + + sources = [ "tester_main.cc" ] + + if (is_win) { + libs = [ + "psapi.lib", + "user32.lib", + "FontSub.lib", + "shlwapi.lib", + ] + } + + defines = [ + "SUPPORT_FRACTIONAL_TRANSLATION=1", + "DISABLE_SOFTWARE_RASTER_CACHE=1", + ] + + deps = [ + "//flutter/assets", + "//flutter/common", + "//flutter/flow", + "//flutter/fml", + "//flutter/lib/snapshot", + "//flutter/shell/common", + "//flutter/shell/gpu:gpu_surface_software", + "//flutter/third_party/tonic", + "//third_party/dart/runtime:libdart_jit", + "//third_party/dart/runtime/bin:dart_io_api", + "//third_party/skia", + ] +} diff --git a/engine/src/flutter/shell/testing/tester_main.cc b/engine/src/flutter/shell/testing/tester_main.cc index e7cd661eb7d..6b9227e2d75 100644 --- a/engine/src/flutter/shell/testing/tester_main.cc +++ b/engine/src/flutter/shell/testing/tester_main.cc @@ -62,6 +62,18 @@ class TesterExternalViewEmbedder : public ExternalViewEmbedder { SkCanvas canvas_; }; +class TesterGPUSurfaceSoftware : public GPUSurfaceSoftware { + public: + TesterGPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate, + bool render_to_surface) + : GPUSurfaceSoftware(delegate, render_to_surface) {} + +#if DISABLE_SOFTWARE_RASTER_CACHE + // |Surface| + bool EnableRasterCache() const override { return false; } +#endif // DISABLE_SOFTWARE_RASTER_CACHE +}; + class TesterPlatformView : public PlatformView, public GPUSurfaceSoftwareDelegate { public: @@ -70,7 +82,7 @@ class TesterPlatformView : public PlatformView, // |PlatformView| std::unique_ptr CreateRenderingSurface() override { - auto surface = std::make_unique( + auto surface = std::make_unique( this, true /* render to surface */); FML_DCHECK(surface->IsValid()); return surface; diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 1826c397a3f..5100c2ee358 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -267,7 +267,7 @@ def RunEngineBenchmarks(build_dir, filter): def RunDartTest(build_dir, test_packages, dart_file, verbose_dart_snapshot, multithreaded, - enable_observatory=False, expect_failure=False): + enable_observatory=False, expect_failure=False, alternative_tester=False): kernel_file_name = os.path.basename(dart_file) + '.dill' kernel_file_output = os.path.join(build_dir, 'gen', kernel_file_name) error_message = "%s doesn't exist. Please run the build that populates %s" % ( @@ -296,9 +296,12 @@ def RunDartTest(build_dir, test_packages, dart_file, verbose_dart_snapshot, mult else: threading = 'single-threaded' - print("Running test '%s' using 'flutter_tester' (%s)" % (kernel_file_name, threading)) + tester_name = 'flutter_tester' + if alternative_tester: + tester_name = 'flutter_tester_fractional_translation' + print("Running test '%s' using '%s' (%s)" % (kernel_file_name, tester_name, threading)) forbidden_output = [] if 'unopt' in build_dir or expect_failure else ['[ERROR'] - RunEngineExecutable(build_dir, 'flutter_tester', None, command_args, + RunEngineExecutable(build_dir, tester_name, None, command_args, forbidden_output=forbidden_output, expect_failure=expect_failure) @@ -442,6 +445,8 @@ def RunDartTests(build_dir, filter, verbose_dart_snapshot): print("Testing dart file %s with observatory enabled" % dart_test_file) RunDartTest(build_dir, test_packages, dart_test_file, verbose_dart_snapshot, True, True) RunDartTest(build_dir, test_packages, dart_test_file, verbose_dart_snapshot, False, True) + # Smoke test with tester variant that has no raster cache and enabled fractional translation + RunDartTest(build_dir, test_packages, dart_test_file, verbose_dart_snapshot, False, True, True) for dart_test_file in dart_tests: if filter is not None and os.path.basename(dart_test_file) not in filter: