Skip to content

Commit

Permalink
WebDriver: Add a --force-cpu-painting option
Browse files Browse the repository at this point in the history
This launches the browser withb the `--force-cpu-backend` option, which
forces Skia to use the CPU backend rather than the GPU.
  • Loading branch information
tcl3 committed Aug 1, 2024
1 parent 739140e commit 180b096
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Ladybird/WebDriver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char c
return result;
}

static ErrorOr<pid_t> launch_browser(ByteString const& socket_path, bool use_qt_networking)
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path, bool use_qt_networking, bool force_cpu_painting)
{
auto arguments = Vector {
"--webdriver-content-path",
Expand All @@ -49,6 +49,8 @@ static ErrorOr<pid_t> launch_browser(ByteString const& socket_path, bool use_qt_
arguments.append("--force-new-process");
if (use_qt_networking)
arguments.append("--enable-qt-networking");
if (force_cpu_painting)
arguments.append("--force-cpu-painting");

arguments.append("about:blank");

Expand All @@ -75,12 +77,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto listen_address = "0.0.0.0"sv;
int port = 8000;
bool enable_qt_networking = false;
bool force_cpu_painting = false;

Core::ArgsParser args_parser;
args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");
args_parser.add_option(port, "Port to listen on", "port", 'p', "port");
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
args_parser.add_option(enable_qt_networking, "Launch browser with Qt networking enabled", "enable-qt-networking");
args_parser.add_option(force_cpu_painting, "Launch browser with GPU painting disabled", "force-cpu-painting");
args_parser.parse(arguments);

auto ipv4_address = IPv4Address::from_string(listen_address);
Expand Down Expand Up @@ -117,7 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}

auto launch_browser_callback = [&](ByteString const& socket_path) {
return launch_browser(socket_path, enable_qt_networking);
return launch_browser(socket_path, enable_qt_networking, force_cpu_painting);
};

auto maybe_client = WebDriver::Client::try_create(maybe_buffered_socket.release_value(), { move(launch_browser_callback), launch_headless_browser }, server);
Expand Down

0 comments on commit 180b096

Please sign in to comment.