+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;
+}
+