src/log.c \
src/compositor.c \
src/compositor.h \
+ src/compositor-headless.h \
src/input.c \
src/data-device.c \
src/screenshooter.c \
westoninclude_HEADERS = \
src/version.h \
src/compositor.h \
+ src/compositor-headless.h \
src/timeline-object.h \
shared/matrix.h \
shared/config-parser.h \
headless_backend_la_CFLAGS = $(COMPOSITOR_CFLAGS) $(AM_CFLAGS)
headless_backend_la_SOURCES = \
src/compositor-headless.c \
+ src/compositor-headless.h \
shared/helpers.h
endif
#include <sys/time.h>
#include <stdbool.h>
-#include "shared/helpers.h"
#include "compositor.h"
+#include "compositor-headless.h"
+#include "shared/helpers.h"
#include "pixman-renderer.h"
#include "presentation-time-server-protocol.h"
struct headless_backend {
struct weston_backend base;
struct weston_compositor *compositor;
+
struct weston_seat fake_seat;
bool use_pixman;
};
struct headless_output {
struct weston_output base;
+
struct weston_mode mode;
struct wl_event_source *finish_frame_timer;
uint32_t *image_buf;
pixman_image_t *image;
};
-struct headless_parameters {
- int width;
- int height;
- int use_pixman;
- uint32_t transform;
-};
-
static void
headless_output_start_repaint_loop(struct weston_output *output)
{
static int
headless_backend_create_output(struct headless_backend *b,
- struct headless_parameters *param)
+ struct weston_headless_backend_config *config)
{
struct weston_compositor *c = b->compositor;
struct headless_output *output;
output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
- output->mode.width = param->width;
- output->mode.height = param->height;
+ output->mode.width = config->width;
+ output->mode.height = config->height;
output->mode.refresh = 60000;
wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
- weston_output_init(&output->base, c, 0, 0, param->width,
- param->height, param->transform, 1);
+ weston_output_init(&output->base, c, 0, 0, config->width,
+ config->height, config->transform, 1);
output->base.make = "weston";
output->base.model = "headless";
output->base.switch_mode = NULL;
if (b->use_pixman) {
- output->image_buf = malloc(param->width * param->height * 4);
+ output->image_buf = malloc(config->width * config->height * 4);
if (!output->image_buf)
return -1;
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
- param->width,
- param->height,
+ config->width,
+ config->height,
output->image_buf,
- param->width * 4);
+ config->width * 4);
if (pixman_renderer_output_create(&output->base) < 0)
return -1;
static struct headless_backend *
headless_backend_create(struct weston_compositor *compositor,
- struct headless_parameters *param,
- const char *display_name)
+ struct weston_headless_backend_config *config)
{
struct headless_backend *b;
b->base.destroy = headless_destroy;
b->base.restore = headless_restore;
- b->use_pixman = param->use_pixman;
+ b->use_pixman = config->use_pixman;
if (b->use_pixman) {
pixman_renderer_init(compositor);
}
- if (headless_backend_create_output(b, param) < 0)
+ if (headless_backend_create_output(b, config) < 0)
goto err_input;
if (!b->use_pixman && noop_renderer_init(compositor) < 0)
return NULL;
}
+static void
+config_init_to_defaults(struct weston_headless_backend_config *config)
+{
+}
+
WL_EXPORT int
backend_init(struct weston_compositor *compositor,
int *argc, char *argv[],
- struct weston_config *config,
+ struct weston_config *wc,
struct weston_backend_config *config_base)
{
- int width = 1024, height = 640;
- char *display_name = NULL;
- struct headless_parameters param = { 0, };
- const char *transform = "normal";
struct headless_backend *b;
+ struct weston_headless_backend_config config = {{ 0, }};
- const struct weston_option headless_options[] = {
- { WESTON_OPTION_INTEGER, "width", 0, &width },
- { WESTON_OPTION_INTEGER, "height", 0, &height },
- { WESTON_OPTION_BOOLEAN, "use-pixman", 0, ¶m.use_pixman },
- { WESTON_OPTION_STRING, "transform", 0, &transform },
- };
-
- parse_options(headless_options,
- ARRAY_LENGTH(headless_options), argc, argv);
-
- param.width = width;
- param.height = height;
+ if (config_base == NULL ||
+ config_base->struct_version != WESTON_HEADLESS_BACKEND_CONFIG_VERSION ||
+ config_base->struct_size > sizeof(struct weston_headless_backend_config)) {
+ weston_log("headless backend config structure is invalid\n");
+ return -1;
+ }
- if (weston_parse_transform(transform, ¶m.transform) < 0)
- weston_log("Invalid transform \"%s\"\n", transform);
+ config_init_to_defaults(&config);
+ memcpy(&config, config_base, config_base->struct_size);
- b = headless_backend_create(compositor, ¶m, display_name);
+ b = headless_backend_create(compositor, &config);
if (b == NULL)
return -1;
+
return 0;
}
--- /dev/null
+/*
+ * Copyright © 2016 Benoit Gschwind
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WESTON_COMPOSITOR_HEADLESS_H
+#define WESTON_COMPOSITOR_HEADLESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "compositor.h"
+
+#define WESTON_HEADLESS_BACKEND_CONFIG_VERSION 1
+
+struct weston_headless_backend_config {
+ struct weston_backend_config base;
+
+ int width;
+ int height;
+
+ /** Whether to use the pixman renderer instead of the OpenGL ES renderer. */
+ int use_pixman;
+
+ uint32_t transform;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WESTON_COMPOSITOR_HEADLESS_H */
#include "git-version.h"
#include "version.h"
+#include "compositor-headless.h"
+
static struct wl_list child_process_list;
static struct weston_compositor *segv_compositor;
}
static int
+load_headless_backend(struct weston_compositor *c, char const * backend,
+ int *argc, char **argv, struct weston_config *wc)
+{
+ struct weston_headless_backend_config config = {{ 0, }};
+ int ret = 0;
+ const char *transform = "normal";
+
+ config.width = 1024;
+ config.height = 640;
+
+ const struct weston_option options[] = {
+ { WESTON_OPTION_INTEGER, "width", 0, &config.width },
+ { WESTON_OPTION_INTEGER, "height", 0, &config.height },
+ { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
+ { WESTON_OPTION_STRING, "transform", 0, &transform },
+ };
+
+ parse_options(options, ARRAY_LENGTH(options), argc, argv);
+
+ if (weston_parse_transform(transform, &config.transform) < 0)
+ weston_log("Invalid transform \"%s\"\n", transform);
+
+ config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION;
+ config.base.struct_size = sizeof(struct weston_headless_backend_config);
+
+ /* load the actual wayland backend and configure it */
+ ret = load_backend_new(c, backend, &config.base);
+
+ return ret;
+}
+
+static int
load_backend(struct weston_compositor *compositor, const char *backend,
int *argc, char **argv, struct weston_config *config)
{
+ if (strstr(backend, "headless-backend.so"))
+ return load_headless_backend(compositor, backend, argc, argv, config);
#if 0
- if (strstr(backend, "drm-backend.so"))
+ else if (strstr(backend, "drm-backend.so"))
return load_drm_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "wayland-backend.so"))
return load_wayland_backend(compositor, backend, argc, argv, config);
return load_x11_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "fbdev-backend.so"))
return load_fbdev_backend(compositor, backend, argc, argv, config);
- else if (strstr(backend, "headless-backend.so"))
- return load_headless_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "rpi-backend.so"))
return load_rpi_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "rdp-backend.so"))