weston/libweston/backend-headless/headless.c

663 lines
16 KiB
C
Raw Normal View History

/*
* Copyright © 2010-2011 Benjamin Franzke
* Copyright © 2012 Intel Corporation
* Copyright © 2013 Jason Ekstrand
* Copyright 2022 Collabora, Ltd.
*
* 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.
*/
#include "config.h"
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <stdbool.h>
#include <libweston/libweston.h>
#include <libweston/backend-headless.h>
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
#include "shared/helpers.h"
libweston: Introduce zwp_linux_explicit_synchronization_v1 Introduce support for the zwp_linux_explicit_synchronization_unstable_v1 protocol with an implementation of the zwp_linux_explicit_synchronization_v1 interface. Explicit synchronization provides a more versatile notification mechanism for buffer readiness and availability, and can be used to improve efficiency by integrating with related functionality in display and graphics APIs. In addition, the per-commit nature of the release events provided by this protocol potentially offers a solution to a deficiency of the wl_buffer.release event (see https://gitlab.freedesktop.org/wayland/wayland/issues/46). Support for this protocol depends on the capabilities of the backend, so we don't register it by default but provide a function which each backend will need to call. In this commit only the headless backend when using the noop renderer supports this to enable testing. Note that the zwp_surface_synchronization_v1 interface, which contains the core functionality of the protocol, is not implemented in this commit. Support for it will be added in future commits. Changes in v7: - Added some information in the commit message about the benefits of the explicit sync protocol. Changes in v6: - Fall back to advertising minor version 1 of the explicit sync protocol, although we support minor version 2 features, until the new wayland-protocols version is released. Changes in v5: - Meson support. - Advertise minor version 2 of the explicit sync protocol. Changes in v4: - Enable explicit sync support in the headless backend for all renderers. Changes in v3: - Use wl_resource_get_version() instead of hardcoding version 1. - Use updated protocol interface names. - Use correct format specifier for resource id. - Change test name to 'linux-explicit-synchronization.weston' (s/_/-/g). Changes in v2: - Move implementation to separate file so protocol can be registered on demand by backends. - Register protocol in headless+noop backend for testing purposes. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
#include "linux-explicit-synchronization.h"
#include "pixel-formats.h"
#include "pixman-renderer.h"
#include "renderer-gl/gl-renderer.h"
#include "gl-borders.h"
#include "shared/weston-drm-fourcc.h"
#include "shared/weston-egl-ext.h"
#include "shared/cairo-util.h"
#include "shared/xalloc.h"
#include "linux-dmabuf.h"
#include "output-capture.h"
#include "presentation-time-server-protocol.h"
#include <libweston/windowed-output-api.h>
struct headless_backend {
struct weston_backend base;
struct weston_compositor *compositor;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
struct weston_seat fake_seat;
bool decorate;
struct theme *theme;
const struct pixel_format_info **formats;
unsigned int formats_count;
};
struct headless_head {
struct weston_head base;
};
struct headless_output {
struct weston_output base;
struct headless_backend *backend;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
struct weston_mode mode;
struct wl_event_source *finish_frame_timer;
struct weston_renderbuffer *renderbuffer;
struct frame *frame;
struct {
struct weston_gl_borders borders;
} gl;
};
static const uint32_t headless_formats[] = {
DRM_FORMAT_XRGB8888, /* default for pixman-renderer */
DRM_FORMAT_ARGB8888,
};
static void
headless_destroy(struct weston_backend *backend);
static inline struct headless_head *
to_headless_head(struct weston_head *base)
{
if (base->backend->destroy != headless_destroy)
return NULL;
return container_of(base, struct headless_head, base);
}
static void
headless_output_destroy(struct weston_output *base);
static inline struct headless_output *
to_headless_output(struct weston_output *base)
{
if (base->destroy != headless_output_destroy)
return NULL;
return container_of(base, struct headless_output, base);
}
static inline struct headless_backend *
to_headless_backend(struct weston_backend *base)
{
return container_of(base, struct headless_backend, base);
}
static int
headless_output_start_repaint_loop(struct weston_output *output)
{
struct timespec ts;
weston_compositor_read_presentation_clock(output->compositor, &ts);
weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID);
return 0;
}
static int
finish_frame_handler(void *data)
{
compositor: set presentation.presented flags Change weston_output_finish_frame() signature so that backends are required to set the flags, that will be reported on the Presentation 'presented' event. This is meant for output-wide feedback flags. Flags that vary per wl_surface are subject for the following patch. All start_repaint_loop functions use the special private flag PRESENTATION_FEEDBACK_INVALID to mark, that this call of weston_output_finish_frame() cannot trigger the 'presented' event. If it does, we now hit an assert, and should then investigate why a fake update triggered Presentation feedback. DRM: Page flip is always vsync'd, and always gets the completion timestamp from the kernel which should correspond well to hardware. Completion is triggered by the kernel/hardware. Vblank handler is only used with the broken planes path, therefore do not report VSYNC, because we cannot guarantee all the planes updated at the same time. We cannot set the INVALID, because it would abort the compositor if the broken planes path was ever used. This is a hack that will get fixed with nuclear pageflip support in the future. fbdev: No vsync, update done by copy, no completion event from hardware, and completion time is totally fake. headless: No real output to update. RDP: Guessing that maybe no vsync, fake time, and copy make sense (pixels sent over network). Also no event that the pixels have been shown? RPI: Presumably Dispmanx updates are vsync'd. We get a completion event from the driver, but need to read the clock ourselves, so the completion time is somewhat unreliable. Zero-copy flag not implemented though it would be theoretically possible with EGL clients (zero-copy is a per-surface flag anyway, so in this patch). Wayland: No information how the host compositor is doing updates, so make a safe guess without assuming vsync or hardware completion event. While we do get some timestamp from the host compositor, it is not the completion time. Would need to hook to the Presentation extension of the host compositor to get more accurate flags. X11: No idea about vsync, completion event, or copying. Also the timestamp is a fake. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com> Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 17:20:40 +03:00
struct headless_output *output = data;
struct timespec ts;
weston_compositor_read_presentation_clock(output->base.compositor, &ts);
compositor: set presentation.presented flags Change weston_output_finish_frame() signature so that backends are required to set the flags, that will be reported on the Presentation 'presented' event. This is meant for output-wide feedback flags. Flags that vary per wl_surface are subject for the following patch. All start_repaint_loop functions use the special private flag PRESENTATION_FEEDBACK_INVALID to mark, that this call of weston_output_finish_frame() cannot trigger the 'presented' event. If it does, we now hit an assert, and should then investigate why a fake update triggered Presentation feedback. DRM: Page flip is always vsync'd, and always gets the completion timestamp from the kernel which should correspond well to hardware. Completion is triggered by the kernel/hardware. Vblank handler is only used with the broken planes path, therefore do not report VSYNC, because we cannot guarantee all the planes updated at the same time. We cannot set the INVALID, because it would abort the compositor if the broken planes path was ever used. This is a hack that will get fixed with nuclear pageflip support in the future. fbdev: No vsync, update done by copy, no completion event from hardware, and completion time is totally fake. headless: No real output to update. RDP: Guessing that maybe no vsync, fake time, and copy make sense (pixels sent over network). Also no event that the pixels have been shown? RPI: Presumably Dispmanx updates are vsync'd. We get a completion event from the driver, but need to read the clock ourselves, so the completion time is somewhat unreliable. Zero-copy flag not implemented though it would be theoretically possible with EGL clients (zero-copy is a per-surface flag anyway, so in this patch). Wayland: No information how the host compositor is doing updates, so make a safe guess without assuming vsync or hardware completion event. While we do get some timestamp from the host compositor, it is not the completion time. Would need to hook to the Presentation extension of the host compositor to get more accurate flags. X11: No idea about vsync, completion event, or copying. Also the timestamp is a fake. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com> Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 17:20:40 +03:00
weston_output_finish_frame(&output->base, &ts, 0);
return 1;
}
static void
headless_output_update_gl_border(struct headless_output *output)
{
if (!output->frame)
return;
if (!(frame_status(output->frame) & FRAME_STATUS_REPAINT))
return;
weston_gl_borders_update(&output->gl.borders, output->frame,
&output->base);
}
static int
headless_output_repaint(struct weston_output *output_base,
pixman_region32_t *damage)
{
struct headless_output *output = to_headless_output(output_base);
struct weston_compositor *ec;
assert(output);
ec = output->base.compositor;
headless_output_update_gl_border(output);
ec->renderer->repaint_output(&output->base, damage,
output->renderbuffer);
pixman_region32_subtract(&ec->primary_plane.damage,
&ec->primary_plane.damage, damage);
wl_event_source_timer_update(output->finish_frame_timer, 16);
return 0;
}
static void
headless_output_disable_gl(struct headless_output *output)
{
struct weston_compositor *compositor = output->base.compositor;
const struct weston_renderer *renderer = compositor->renderer;
weston_gl_borders_fini(&output->gl.borders, &output->base);
weston_renderbuffer_unref(output->renderbuffer);
output->renderbuffer = NULL;
renderer->gl->output_destroy(&output->base);
if (output->frame) {
frame_destroy(output->frame);
output->frame = NULL;
}
}
static void
headless_output_disable_pixman(struct headless_output *output)
{
struct weston_renderer *renderer = output->base.compositor->renderer;
weston_renderbuffer_unref(output->renderbuffer);
output->renderbuffer = NULL;
renderer->pixman->output_destroy(&output->base);
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
static int
headless_output_disable(struct weston_output *base)
{
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
struct headless_output *output = to_headless_output(base);
struct headless_backend *b;
assert(output);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
if (!output->base.enabled)
return 0;
b = output->backend;
wl_event_source_remove(output->finish_frame_timer);
switch (b->compositor->renderer->type) {
case WESTON_RENDERER_GL:
headless_output_disable_gl(output);
break;
case WESTON_RENDERER_PIXMAN:
headless_output_disable_pixman(output);
break;
case WESTON_RENDERER_NOOP:
break;
case WESTON_RENDERER_AUTO:
unreachable("cannot have auto renderer at runtime");
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
return 0;
}
static void
headless_output_destroy(struct weston_output *base)
{
struct headless_output *output = to_headless_output(base);
assert(output);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
headless_output_disable(&output->base);
weston_output_release(&output->base);
assert(!output->frame);
free(output);
}
static int
headless_output_enable_gl(struct headless_output *output)
{
struct headless_backend *b = output->backend;
const struct weston_renderer *renderer = b->compositor->renderer;
const struct weston_mode *mode = output->base.current_mode;
struct gl_renderer_fbo_options options = { 0 };
if (b->decorate) {
/*
* Start with a dummy exterior size and then resize, because
* there is no frame_create() with interior size.
*/
output->frame = frame_create(b->theme, 100, 100,
FRAME_BUTTON_CLOSE, NULL, NULL);
if (!output->frame) {
weston_log("failed to create frame for output\n");
return -1;
}
frame_resize_inside(output->frame, mode->width, mode->height);
options.fb_size.width = frame_width(output->frame);
options.fb_size.height = frame_height(output->frame);
frame_interior(output->frame, &options.area.x, &options.area.y,
&options.area.width, &options.area.height);
} else {
options.area.x = 0;
options.area.y = 0;
options.area.width = mode->width;
options.area.height = mode->height;
options.fb_size.width = mode->width;
options.fb_size.height = mode->height;
}
if (renderer->gl->output_fbo_create(&output->base, &options) < 0) {
weston_log("failed to create gl renderer output state\n");
if (output->frame) {
frame_destroy(output->frame);
output->frame = NULL;
}
return -1;
}
output->renderbuffer =
renderer->gl->create_fbo(&output->base, b->formats[0],
options.fb_size.width,
options.fb_size.height, NULL);
if (!output->renderbuffer)
goto err_renderbuffer;
return 0;
err_renderbuffer:
renderer->gl->output_destroy(&output->base);
return -1;
}
static int
headless_output_enable_pixman(struct headless_output *output)
{
const struct pixman_renderer_interface *pixman;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
.fb_size = {
.width = output->base.current_mode->width,
.height = output->base.current_mode->height
},
.format = pixel_format_get_info(headless_formats[0])
};
pixman = output->base.compositor->renderer->pixman;
if (pixman->output_create(&output->base, &options) < 0)
return -1;
output->renderbuffer =
pixman->create_image(&output->base, options.format,
output->base.current_mode->width,
output->base.current_mode->height);
if (!output->renderbuffer)
goto err_renderer;
return 0;
err_renderer:
pixman->output_destroy(&output->base);
return -1;
}
static int
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
headless_output_enable(struct weston_output *base)
{
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
struct headless_output *output = to_headless_output(base);
struct headless_backend *b;
struct wl_event_loop *loop;
int ret = 0;
assert(output);
b = output->backend;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
if (output->finish_frame_timer == NULL) {
weston_log("failed to add finish frame timer\n");
return -1;
}
switch (b->compositor->renderer->type) {
case WESTON_RENDERER_GL:
ret = headless_output_enable_gl(output);
break;
case WESTON_RENDERER_PIXMAN:
ret = headless_output_enable_pixman(output);
break;
case WESTON_RENDERER_NOOP:
break;
case WESTON_RENDERER_AUTO:
unreachable("cannot have auto renderer at runtime");
}
if (ret < 0) {
wl_event_source_remove(output->finish_frame_timer);
return -1;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
}
return 0;
}
static int
headless_output_set_size(struct weston_output *base,
int width, int height)
{
struct headless_output *output = to_headless_output(base);
struct weston_head *head;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
int output_width, output_height;
if (!output)
return -1;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
/* We can only be called once. */
assert(!output->base.current_mode);
/* Make sure we have scale set. */
assert(output->base.scale);
wl_list_for_each(head, &output->base.head_list, output_link) {
weston_head_set_monitor_strings(head, "weston", "headless",
NULL);
/* XXX: Calculate proper size. */
weston_head_set_physical_size(head, width, height);
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
output_width = width * output->base.scale;
output_height = height * output->base.scale;
output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
output->mode.width = output_width;
output->mode.height = output_height;
output->mode.refresh = 60000;
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
output->base.start_repaint_loop = headless_output_start_repaint_loop;
output->base.repaint = headless_output_repaint;
output->base.assign_planes = NULL;
output->base.set_backlight = NULL;
output->base.set_dpms = NULL;
output->base.switch_mode = NULL;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
return 0;
}
static struct weston_output *
headless_output_create(struct weston_backend *backend, const char *name)
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
{
struct headless_backend *b = container_of(backend, struct headless_backend, base);
struct weston_compositor *compositor = b->compositor;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
struct headless_output *output;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
/* name can't be NULL. */
assert(name);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
output = zalloc(sizeof *output);
if (!output)
return NULL;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
weston_output_init(&output->base, compositor, name);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
output->base.destroy = headless_output_destroy;
output->base.disable = headless_output_disable;
output->base.enable = headless_output_enable;
output->base.attach_head = NULL;
output->backend = b;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
weston_compositor_add_pending_output(&output->base, compositor);
return &output->base;
}
static int
headless_head_create(struct weston_backend *base,
const char *name)
{
struct headless_backend *backend = to_headless_backend(base);
struct headless_head *head;
/* name can't be NULL. */
assert(name);
head = zalloc(sizeof *head);
if (head == NULL)
return -1;
weston_head_init(&head->base, name);
head->base.backend = &backend->base;
weston_head_set_connection_status(&head->base, true);
weston_head_set_supported_eotf_mask(&head->base,
WESTON_EOTF_MODE_ALL_MASK);
/* Ideally all attributes of the head would be set here, so that the
* user has all the information when deciding to create outputs.
* We do not have those until set_size() time through.
*/
weston_compositor_add_head(backend->compositor, &head->base);
return 0;
}
static void
headless_head_destroy(struct weston_head *base)
{
struct headless_head *head = to_headless_head(base);
assert(head);
weston_head_release(&head->base);
free(head);
}
static void
headless_destroy(struct weston_backend *backend)
{
struct headless_backend *b = container_of(backend, struct headless_backend, base);
struct weston_compositor *ec = b->compositor;
struct weston_head *base, *next;
weston_compositor_shutdown(ec);
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link) {
if (to_headless_head(base))
headless_head_destroy(base);
}
if (b->theme)
theme_destroy(b->theme);
free(b->formats);
free(b);
backend-headless: fully release pango and fontconfig In the color-icc-output test, this fixes the following ASan reports: Direct leak of 6912 byte(s) in 27 object(s) allocated from: #0 0x7f36bf0a9e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7f36bd9c2704 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20704) #2 0x7f36bd9c2dc8 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20dc8) #3 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #4 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #5 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #6 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #7 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #9 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #10 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #11 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #12 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #13 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #14 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #15 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #17 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #18 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #19 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #20 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #21 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #23 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #24 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #25 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #26 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #27 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #28 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #29 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) Indirect leak of 1696 byte(s) in 53 object(s) allocated from: #0 0x7f36bf0aa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 #1 0x7f36bd9c2d48 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d48) #2 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #3 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #4 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #5 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #6 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #7 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #8 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #9 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #10 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #11 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #12 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #13 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #14 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #15 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #16 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #17 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #18 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #19 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #20 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #21 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #22 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #23 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #24 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #25 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #26 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #27 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #28 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #29 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #30 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #31 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #32 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #33 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #34 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #35 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #36 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #37 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #38 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #39 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #40 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #41 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #42 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #43 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #44 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #45 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #46 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #47 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #48 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) Indirect leak of 537 byte(s) in 52 object(s) allocated from: #0 0x7f36bf057817 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:452 #1 0x7f36bd9c1fa4 in FcValueSave (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1ffa4) #2 0x7f36bd9c2d5d (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d5d) #3 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #4 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #5 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #6 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #7 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #9 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #10 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #11 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #12 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #13 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #14 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #15 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #17 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #18 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #19 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #20 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #21 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #23 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #24 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #25 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #26 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #27 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #28 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #29 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) SUMMARY: AddressSanitizer: 9145 byte(s) leaked in 132 allocation(s). We do the clean-up unconditionally because xwayland plugin may also need it, but cannot easily do it itself. This reduces reported leaks in xwayland test too. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-12 13:55:07 +03:00
/* XXX: cleaning up after cairo/fontconfig here might seem suitable,
* but fontconfig will create additional threads which we can't wait
* for -- in order to realiably de-allocate all resources, as to get a
* report without any mem leaks. */
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
static const struct weston_windowed_output_api api = {
headless_output_set_size,
headless_head_create,
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
};
static struct headless_backend *
headless_backend_create(struct weston_compositor *compositor,
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
struct weston_headless_backend_config *config)
{
struct headless_backend *b;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
int ret;
b = zalloc(sizeof *b);
if (b == NULL)
return NULL;
b->compositor = compositor;
compositor->backend = &b->base;
if (weston_compositor_set_presentation_clock_software(compositor) < 0)
goto err_free;
b->base.destroy = headless_destroy;
b->base.create_output = headless_output_create;
b->decorate = config->decorate;
if (b->decorate) {
b->theme = theme_create();
if (!b->theme) {
weston_log("Error: could not load decorations theme.\n");
goto err_free;
}
}
b->formats_count = ARRAY_LENGTH(headless_formats);
b->formats = pixel_format_get_array(headless_formats, b->formats_count);
switch (config->renderer) {
case WESTON_RENDERER_GL: {
const struct gl_renderer_display_options options = {
.egl_platform = EGL_PLATFORM_SURFACELESS_MESA,
.egl_native_display = NULL,
.formats = b->formats,
.formats_count = b->formats_count,
};
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_GL,
&options.base);
break;
}
case WESTON_RENDERER_PIXMAN:
if (config->decorate) {
weston_log("Error: Pixman renderer does not support decorations.\n");
goto err_input;
}
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_PIXMAN,
NULL);
break;
case WESTON_RENDERER_AUTO:
case WESTON_RENDERER_NOOP:
if (config->decorate) {
weston_log("Error: no-op renderer does not support decorations.\n");
goto err_input;
}
ret = noop_renderer_init(compositor);
break;
default:
weston_log("Error: unsupported renderer\n");
break;
}
if (ret < 0)
goto err_input;
if (compositor->renderer->import_dmabuf) {
if (linux_dmabuf_setup(compositor) < 0) {
weston_log("Error: dmabuf protocol setup failed.\n");
goto err_input;
}
}
libweston: Introduce zwp_linux_explicit_synchronization_v1 Introduce support for the zwp_linux_explicit_synchronization_unstable_v1 protocol with an implementation of the zwp_linux_explicit_synchronization_v1 interface. Explicit synchronization provides a more versatile notification mechanism for buffer readiness and availability, and can be used to improve efficiency by integrating with related functionality in display and graphics APIs. In addition, the per-commit nature of the release events provided by this protocol potentially offers a solution to a deficiency of the wl_buffer.release event (see https://gitlab.freedesktop.org/wayland/wayland/issues/46). Support for this protocol depends on the capabilities of the backend, so we don't register it by default but provide a function which each backend will need to call. In this commit only the headless backend when using the noop renderer supports this to enable testing. Note that the zwp_surface_synchronization_v1 interface, which contains the core functionality of the protocol, is not implemented in this commit. Support for it will be added in future commits. Changes in v7: - Added some information in the commit message about the benefits of the explicit sync protocol. Changes in v6: - Fall back to advertising minor version 1 of the explicit sync protocol, although we support minor version 2 features, until the new wayland-protocols version is released. Changes in v5: - Meson support. - Advertise minor version 2 of the explicit sync protocol. Changes in v4: - Enable explicit sync support in the headless backend for all renderers. Changes in v3: - Use wl_resource_get_version() instead of hardcoding version 1. - Use updated protocol interface names. - Use correct format specifier for resource id. - Change test name to 'linux-explicit-synchronization.weston' (s/_/-/g). Changes in v2: - Move implementation to separate file so protocol can be registered on demand by backends. - Register protocol in headless+noop backend for testing purposes. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
/* Support zwp_linux_explicit_synchronization_unstable_v1 to enable
* testing. */
if (linux_explicit_synchronization_setup(compositor) < 0)
goto err_input;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 15:11:07 +03:00
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
&api, sizeof(api));
if (ret < 0) {
weston_log("Failed to register output API.\n");
goto err_input;
}
return b;
err_input:
if (b->theme)
theme_destroy(b->theme);
weston_compositor_shutdown(compositor);
err_free:
free(b);
return NULL;
}
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
static void
config_init_to_defaults(struct weston_headless_backend_config *config)
{
}
WL_EXPORT int
weston_backend_init(struct weston_compositor *compositor,
struct weston_backend_config *config_base)
{
struct headless_backend *b;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
struct weston_headless_backend_config config = {{ 0, }};
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
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;
}
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
config_init_to_defaults(&config);
memcpy(&config, config_base, config_base->struct_size);
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
b = headless_backend_create(compositor, &config);
if (b == NULL)
return -1;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 06:28:32 +03:00
return 0;
}