From 61dff3ff317c4d686b481cb808f98c51f7b743c3 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 20 Apr 2021 12:40:19 +0300 Subject: main: Add support for loading the headless-backend For making use of the testing framework/harness we should be able to load up the headless backend. This patch adds support for loading it. Bug-AGL: SPEC-3887 Signed-off-by: Marius Vlad Change-Id: I569ad3e562cd0a90094c6238ca02ed00e4106b10 --- src/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/main.c b/src/main.c index 482558a..340d0e0 100644 --- a/src/main.c +++ b/src/main.c @@ -39,6 +39,7 @@ #include #include +#include #ifdef HAVE_BACKEND_X11 #include #endif @@ -289,6 +290,8 @@ windowed_configure_output(struct ivi_output *output) return -1; } + weston_log("Configured windowed_output_api to %dx%d\n", width, height); + return 0; } @@ -1084,6 +1087,54 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) } #endif +static int +load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv) +{ + struct weston_headless_backend_config config = {}; + int ret = 0; + + bool use_pixman; + bool fullscreen; + bool use_gl; + int output_count; + + struct weston_compositor *c = ivi->compositor; + + const struct weston_option options[] = { + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman }, + { WESTON_OPTION_BOOLEAN, "use-gl", 0, &use_gl }, + }; + + windowed_parse_common_options(ivi, argc, argv, &use_pixman, + &fullscreen, &output_count); + + parse_options(options, ARRAY_LENGTH(options), argc, argv); + config.use_pixman = use_pixman; + config.use_gl = use_gl; + + config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION; + config.base.struct_size = sizeof(struct weston_headless_backend_config); + + /* load the actual headless-backend and configure it */ + ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS, + &config.base); + if (ret < 0) + return ret; + + ivi->window_api = weston_windowed_output_get_api(c); + if (!ivi->window_api) { + weston_log("Cannot use weston_windowed_output_api.\n"); + return -1; + } + + if (ivi->window_api->create_head(c, "headless") < 0) { + weston_log("Cannot create headless back-end\n"); + return -1; + } + + return 0; +} + static int load_backend(struct ivi_compositor *ivi, const char *backend, int *argc, char *argv[]) @@ -1094,6 +1145,8 @@ load_backend(struct ivi_compositor *ivi, const char *backend, return load_wayland_backend(ivi, argc, argv); } else if (strcmp(backend, "x11-backend.so") == 0) { return load_x11_backend(ivi, argc, argv); + } else if (strcmp(backend, "headless-backend.so") == 0) { + return load_headless_backend(ivi, argc, argv); } weston_log("fatal: unknown backend '%s'.\n", backend); @@ -1437,6 +1490,7 @@ usage(int error_code) "\t\t\t\tdrm-backend.so\n" "\t\t\t\twayland-backend.so\n" "\t\t\t\tx11-backend.so\n" + "\t\t\t\theadless-backend.so\n" " -S, --socket=NAME\tName of socket to listen on\n" " --log=FILE\t\tLog to the given file\n" " -c, --config=FILE\tConfig file to load, defaults to agl-compositor.ini\n" -- cgit 1.2.3-korg