LibWebView+WebContent: Add a --force-cpu-painting option

This option forces Skia to use the CPU backend rather than using the
GPU.
This commit is contained in:
Tim Ledbetter
2024-08-01 18:49:24 +01:00
committed by Tim Ledbetter
parent 3eb5c63df3
commit 2854113ee6
4 changed files with 18 additions and 3 deletions

View File

@@ -104,6 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool log_all_js_exceptions = false;
bool enable_idl_tracing = false;
bool enable_http_cache = false;
bool force_cpu_painting = false;
Core::ArgsParser args_parser;
args_parser.add_option(command_line, "Chrome process command line", "command-line", 0, "command_line");
@@ -120,6 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
args_parser.parse(arguments);
@@ -127,15 +129,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Core::Process::wait_for_debugger_and_break();
}
// Layout test mode implies internals object is exposed
if (is_layout_test_mode)
// Layout test mode implies internals object is exposed and the Skia CPU backend is used
if (is_layout_test_mode) {
expose_internals_object = true;
force_cpu_painting = true;
}
Web::set_chrome_process_command_line(command_line);
Web::set_chrome_process_executable_path(executable_path);
// Always use the CPU backend for layout tests, as the GPU backend is not deterministic
WebContent::PageClient::set_use_skia_painter(is_layout_test_mode ? WebContent::PageClient::UseSkiaPainter::CPUBackend : WebContent::PageClient::UseSkiaPainter::GPUBackendIfAvailable);
WebContent::PageClient::set_use_skia_painter(force_cpu_painting ? WebContent::PageClient::UseSkiaPainter::CPUBackend : WebContent::PageClient::UseSkiaPainter::GPUBackendIfAvailable);
if (enable_http_cache) {
Web::Fetch::Fetching::g_http_cache_enabled = true;