2008-12-02 23:15:01 +03:00
|
|
|
/*
|
Change remaining GPLv2 headers to MIT
The files in question are copyright Benjamin Franzke (who agrees),
Intel Corporation, Red Hat and myself. On behalf of Red Hat,
Richard Fontana says:
"Therefore, to the extent that Red Hat, Inc. has any copyright
interest in the files you cited as of this date (compositor-drm.c,
compositor.c, compositor.h, screenshooter.c in
http://cgit.freedesktop.org/wayland/wayland-demos/tree/compositor),
Red Hat hereby elects to apply the CC0 1.0 Universal Public Domain
Dedication to such copyrighted material. See:
http://creativecommons.org/publicdomain/zero/1.0/legalcode .
Thanks,
Richard E. Fontana
Open Source Licensing and Patent Counsel
Red Hat, Inc."
2011-09-15 23:43:14 +04:00
|
|
|
* Copyright © 2010-2011 Intel Corporation
|
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
2021-04-30 14:48:52 +03:00
|
|
|
* Copyright © 2012-2018, 2021 Collabora, Ltd.
|
2018-04-19 14:20:01 +03:00
|
|
|
* Copyright © 2017, 2018 General Electric Company
|
2008-12-02 23:15:01 +03:00
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* 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:
|
2008-12-02 23:15:01 +03:00
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* 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.
|
2008-12-02 23:15:01 +03:00
|
|
|
*/
|
|
|
|
|
2011-01-15 01:22:35 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-06-01 15:14:06 +04:00
|
|
|
#include <fcntl.h>
|
2008-10-09 06:51:32 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
2011-03-11 18:39:20 +03:00
|
|
|
#include <limits.h>
|
2008-11-09 08:22:51 +03:00
|
|
|
#include <stdarg.h>
|
2011-06-21 21:34:19 +04:00
|
|
|
#include <assert.h>
|
2008-10-09 06:51:32 +04:00
|
|
|
#include <sys/ioctl.h>
|
2012-06-01 15:14:06 +04:00
|
|
|
#include <sys/mman.h>
|
2011-06-22 01:32:25 +04:00
|
|
|
#include <sys/wait.h>
|
2011-12-02 17:30:21 +04:00
|
|
|
#include <sys/socket.h>
|
2012-06-11 02:57:39 +04:00
|
|
|
#include <sys/utsname.h>
|
2012-06-18 22:15:18 +04:00
|
|
|
#include <sys/stat.h>
|
2008-10-09 06:51:32 +04:00
|
|
|
#include <unistd.h>
|
2008-11-24 01:07:32 +03:00
|
|
|
#include <math.h>
|
2010-06-11 20:56:24 +04:00
|
|
|
#include <linux/input.h>
|
2011-04-23 21:04:11 +04:00
|
|
|
#include <dlfcn.h>
|
2011-05-02 20:11:07 +04:00
|
|
|
#include <signal.h>
|
2012-01-16 20:53:54 +04:00
|
|
|
#include <setjmp.h>
|
2012-06-09 00:16:52 +04:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
2014-08-27 14:31:26 +04:00
|
|
|
#include <errno.h>
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
#include <inttypes.h>
|
2022-01-14 04:55:50 +03:00
|
|
|
#include <drm_fourcc.h>
|
2008-12-30 22:31:33 +03:00
|
|
|
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
#include "timeline.h"
|
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2019-06-21 22:49:18 +03:00
|
|
|
#include <libweston/weston-log.h>
|
2018-07-20 11:46:24 +03:00
|
|
|
#include "linux-dmabuf.h"
|
2016-04-15 14:47:08 +03:00
|
|
|
#include "viewporter-server-protocol.h"
|
2016-02-18 17:53:27 +03:00
|
|
|
#include "presentation-time-server-protocol.h"
|
2019-03-29 15:01:06 +03:00
|
|
|
#include "xdg-output-unstable-v1-server-protocol.h"
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
#include "linux-explicit-synchronization-unstable-v1-server-protocol.h"
|
2018-10-19 12:14:11 +03:00
|
|
|
#include "linux-explicit-synchronization.h"
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
#include "shared/fd-util.h"
|
2015-06-16 01:37:08 +03:00
|
|
|
#include "shared/helpers.h"
|
2015-06-16 01:37:07 +03:00
|
|
|
#include "shared/os-compatibility.h"
|
2016-08-04 03:40:52 +03:00
|
|
|
#include "shared/string-helpers.h"
|
2015-07-03 15:44:50 +03:00
|
|
|
#include "shared/timespec-util.h"
|
2020-07-09 17:31:34 +03:00
|
|
|
#include "shared/signal.h"
|
2012-06-09 00:16:52 +04:00
|
|
|
#include "git-version.h"
|
2019-04-04 15:41:02 +03:00
|
|
|
#include <libweston/version.h>
|
2019-03-29 18:07:34 +03:00
|
|
|
#include <libweston/plugin-registry.h>
|
2018-11-20 18:52:31 +03:00
|
|
|
#include "pixel-formats.h"
|
2019-07-16 23:34:14 +03:00
|
|
|
#include "backend.h"
|
2019-07-10 13:46:39 +03:00
|
|
|
#include "libweston-internal.h"
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
#include "color.h"
|
2008-12-12 07:18:45 +03:00
|
|
|
|
2019-07-09 00:36:20 +03:00
|
|
|
#include "weston-log-internal.h"
|
|
|
|
|
2019-06-11 00:05:08 +03:00
|
|
|
/**
|
|
|
|
* \defgroup head Head
|
|
|
|
* \defgroup output Output
|
|
|
|
* \defgroup compositor Compositor
|
|
|
|
*/
|
|
|
|
|
2014-05-21 17:17:27 +04:00
|
|
|
#define DEFAULT_REPAINT_WINDOW 7 /* milliseconds */
|
|
|
|
|
2017-03-29 17:01:41 +03:00
|
|
|
static void
|
|
|
|
weston_output_update_matrix(struct weston_output *output);
|
|
|
|
|
2012-12-14 19:37:25 +04:00
|
|
|
static void
|
2013-05-28 18:23:36 +04:00
|
|
|
weston_output_transform_scale_init(struct weston_output *output,
|
|
|
|
uint32_t transform, uint32_t scale);
|
2012-12-14 19:37:25 +04:00
|
|
|
|
2013-06-26 21:08:46 +04:00
|
|
|
static void
|
2021-04-30 14:48:52 +03:00
|
|
|
weston_compositor_build_view_list(struct weston_compositor *compositor,
|
|
|
|
struct weston_output *output);
|
2013-06-26 21:08:46 +04:00
|
|
|
|
2017-12-08 15:13:34 +03:00
|
|
|
static char *
|
|
|
|
weston_output_create_heads_string(struct weston_output *output);
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
static struct weston_paint_node *
|
|
|
|
weston_paint_node_create(struct weston_surface *surface,
|
|
|
|
struct weston_view *view,
|
|
|
|
struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct weston_paint_node *pnode;
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
struct weston_paint_node *existing_node;
|
2021-04-30 14:48:52 +03:00
|
|
|
|
|
|
|
assert(view->surface == surface);
|
|
|
|
|
|
|
|
pnode = zalloc(sizeof *pnode);
|
|
|
|
if (!pnode)
|
|
|
|
return NULL;
|
|
|
|
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
/*
|
|
|
|
* Invariant: all paint nodes with the same surface+output have the
|
|
|
|
* same surf_xform state.
|
|
|
|
*/
|
2022-01-24 14:09:01 +03:00
|
|
|
wl_list_for_each(existing_node, &surface->paint_node_list, surface_link) {
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
assert(existing_node->surface == surface);
|
|
|
|
if (existing_node->output != output)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
weston_surface_color_transform_copy(&pnode->surf_xform,
|
|
|
|
&existing_node->surf_xform);
|
|
|
|
pnode->surf_xform_valid = existing_node->surf_xform_valid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
pnode->surface = surface;
|
|
|
|
wl_list_insert(&surface->paint_node_list, &pnode->surface_link);
|
|
|
|
|
|
|
|
pnode->view = view;
|
|
|
|
wl_list_insert(&view->paint_node_list, &pnode->view_link);
|
|
|
|
|
|
|
|
pnode->output = output;
|
|
|
|
wl_list_insert(&output->paint_node_list, &pnode->output_link);
|
|
|
|
|
2021-04-30 17:41:29 +03:00
|
|
|
wl_list_init(&pnode->z_order_link);
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
return pnode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_paint_node_destroy(struct weston_paint_node *pnode)
|
|
|
|
{
|
|
|
|
assert(pnode->view->surface == pnode->surface);
|
|
|
|
wl_list_remove(&pnode->surface_link);
|
|
|
|
wl_list_remove(&pnode->view_link);
|
|
|
|
wl_list_remove(&pnode->output_link);
|
2021-04-30 17:41:29 +03:00
|
|
|
wl_list_remove(&pnode->z_order_link);
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
assert(pnode->surf_xform_valid || !pnode->surf_xform.transform);
|
|
|
|
weston_surface_color_transform_fini(&pnode->surf_xform);
|
2021-04-30 14:48:52 +03:00
|
|
|
free(pnode);
|
|
|
|
}
|
|
|
|
|
2017-03-28 15:27:10 +03:00
|
|
|
/** Send wl_output events for mode and scale changes
|
|
|
|
*
|
|
|
|
* \param head Send on all resources bound to this head.
|
|
|
|
* \param mode_changed If true, send the current mode.
|
|
|
|
* \param scale_changed If true, send the current scale.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_mode_switch_send_events(struct weston_head *head,
|
|
|
|
bool mode_changed, bool scale_changed)
|
|
|
|
{
|
|
|
|
struct weston_output *output = head->output;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
int version;
|
|
|
|
|
|
|
|
wl_resource_for_each(resource, &head->resource_list) {
|
|
|
|
if (mode_changed) {
|
|
|
|
wl_output_send_mode(resource,
|
|
|
|
output->current_mode->flags,
|
|
|
|
output->current_mode->width,
|
|
|
|
output->current_mode->height,
|
|
|
|
output->current_mode->refresh);
|
|
|
|
}
|
|
|
|
|
|
|
|
version = wl_resource_get_version(resource);
|
|
|
|
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
|
|
|
|
wl_output_send_scale(resource, output->current_scale);
|
|
|
|
|
|
|
|
if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
|
|
|
|
wl_output_send_done(resource);
|
|
|
|
}
|
2019-03-29 15:01:06 +03:00
|
|
|
wl_resource_for_each(resource, &head->xdg_output_resource_list) {
|
|
|
|
zxdg_output_v1_send_logical_position(resource,
|
|
|
|
output->x,
|
|
|
|
output->y);
|
|
|
|
zxdg_output_v1_send_logical_size(resource,
|
|
|
|
output->width,
|
|
|
|
output->height);
|
|
|
|
zxdg_output_v1_send_done(resource);
|
|
|
|
}
|
2017-03-28 15:27:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_mode_switch_finish(struct weston_output *output,
|
|
|
|
int mode_changed, int scale_changed)
|
2012-04-17 13:20:47 +04:00
|
|
|
{
|
2012-12-14 19:37:26 +04:00
|
|
|
struct weston_seat *seat;
|
2017-03-27 12:15:38 +03:00
|
|
|
struct weston_head *head;
|
2012-12-14 19:37:26 +04:00
|
|
|
pixman_region32_t old_output_region;
|
2013-05-28 18:23:38 +04:00
|
|
|
|
2012-12-14 19:37:26 +04:00
|
|
|
pixman_region32_init(&old_output_region);
|
|
|
|
pixman_region32_copy(&old_output_region, &output->region);
|
|
|
|
|
2012-12-14 19:37:25 +04:00
|
|
|
/* Update output region and transformation matrix */
|
2013-09-19 01:56:35 +04:00
|
|
|
weston_output_transform_scale_init(output, output->transform, output->current_scale);
|
2012-12-14 19:37:25 +04:00
|
|
|
|
|
|
|
pixman_region32_init_rect(&output->region, output->x, output->y,
|
|
|
|
output->width, output->height);
|
|
|
|
|
|
|
|
weston_output_update_matrix(output);
|
|
|
|
|
2012-12-14 19:37:26 +04:00
|
|
|
/* If a pointer falls outside the outputs new geometry, move it to its
|
|
|
|
* lower-right corner */
|
|
|
|
wl_list_for_each(seat, &output->compositor->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
2012-12-14 19:37:26 +04:00
|
|
|
int32_t x, y;
|
|
|
|
|
|
|
|
if (!pointer)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x = wl_fixed_to_int(pointer->x);
|
|
|
|
y = wl_fixed_to_int(pointer->y);
|
|
|
|
|
|
|
|
if (!pixman_region32_contains_point(&old_output_region,
|
|
|
|
x, y, NULL) ||
|
|
|
|
pixman_region32_contains_point(&output->region,
|
|
|
|
x, y, NULL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (x >= output->x + output->width)
|
|
|
|
x = output->x + output->width - 1;
|
|
|
|
if (y >= output->y + output->height)
|
|
|
|
y = output->y + output->height - 1;
|
|
|
|
|
|
|
|
pointer->x = wl_fixed_from_int(x);
|
|
|
|
pointer->y = wl_fixed_from_int(y);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_fini(&old_output_region);
|
|
|
|
|
2014-11-10 19:29:59 +03:00
|
|
|
if (!mode_changed && !scale_changed)
|
|
|
|
return;
|
|
|
|
|
2013-09-19 01:56:36 +04:00
|
|
|
/* notify clients of the changes */
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link)
|
|
|
|
weston_mode_switch_send_events(head,
|
|
|
|
mode_changed, scale_changed);
|
2014-11-04 19:47:33 +03:00
|
|
|
}
|
|
|
|
|
2016-05-28 00:22:57 +03:00
|
|
|
static void
|
|
|
|
weston_compositor_reflow_outputs(struct weston_compositor *compositor,
|
|
|
|
struct weston_output *resized_output, int delta_width);
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2014-11-04 19:47:33 +03:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_output_mode_set_native(struct weston_output *output,
|
|
|
|
struct weston_mode *mode,
|
|
|
|
int32_t scale)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int mode_changed = 0, scale_changed = 0;
|
2016-05-28 00:22:57 +03:00
|
|
|
int32_t old_width;
|
2014-11-04 19:47:33 +03:00
|
|
|
|
|
|
|
if (!output->switch_mode)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!output->original_mode) {
|
|
|
|
mode_changed = 1;
|
|
|
|
ret = output->switch_mode(output, mode);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
if (output->current_scale != scale) {
|
|
|
|
scale_changed = 1;
|
|
|
|
output->current_scale = scale;
|
2013-09-19 01:56:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-28 00:22:57 +03:00
|
|
|
old_width = output->width;
|
2014-11-04 19:47:33 +03:00
|
|
|
output->native_mode = mode;
|
|
|
|
output->native_scale = scale;
|
|
|
|
|
|
|
|
weston_mode_switch_finish(output, mode_changed, scale_changed);
|
|
|
|
|
2016-05-28 00:22:57 +03:00
|
|
|
if (mode_changed || scale_changed) {
|
|
|
|
weston_compositor_reflow_outputs(output->compositor, output, output->width - old_width);
|
|
|
|
|
|
|
|
wl_signal_emit(&output->compositor->output_resized_signal, output);
|
|
|
|
}
|
2014-11-04 19:47:33 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2014-11-04 19:47:33 +03:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_output_mode_switch_to_native(struct weston_output *output)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int mode_changed = 0, scale_changed = 0;
|
|
|
|
|
|
|
|
if (!output->switch_mode)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!output->original_mode) {
|
|
|
|
weston_log("already in the native mode\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* the non fullscreen clients haven't seen a mode set since we
|
|
|
|
* switched into a temporary, so we need to notify them if the
|
|
|
|
* mode at that time is different from the native mode now.
|
|
|
|
*/
|
|
|
|
mode_changed = (output->original_mode != output->native_mode);
|
|
|
|
scale_changed = (output->original_scale != output->native_scale);
|
|
|
|
|
|
|
|
ret = output->switch_mode(output, output->native_mode);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
output->current_scale = output->native_scale;
|
|
|
|
|
|
|
|
output->original_mode = NULL;
|
|
|
|
output->original_scale = 0;
|
|
|
|
|
|
|
|
weston_mode_switch_finish(output, mode_changed, scale_changed);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2014-11-04 19:47:33 +03:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_output_mode_switch_to_temporary(struct weston_output *output,
|
|
|
|
struct weston_mode *mode,
|
|
|
|
int32_t scale)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!output->switch_mode)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* original_mode is the last mode non full screen clients have seen,
|
|
|
|
* so we shouldn't change it if we already have one set.
|
|
|
|
*/
|
|
|
|
if (!output->original_mode) {
|
|
|
|
output->original_mode = output->native_mode;
|
|
|
|
output->original_scale = output->native_scale;
|
|
|
|
}
|
|
|
|
ret = output->switch_mode(output, mode);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
output->current_scale = scale;
|
|
|
|
|
|
|
|
weston_mode_switch_finish(output, 0, 0);
|
|
|
|
|
|
|
|
return 0;
|
2012-04-17 13:20:47 +04:00
|
|
|
}
|
|
|
|
|
2012-02-28 19:59:33 +04:00
|
|
|
static void
|
2012-10-10 13:49:28 +04:00
|
|
|
region_init_infinite(pixman_region32_t *region)
|
2012-02-28 19:59:33 +04:00
|
|
|
{
|
2012-10-10 13:49:28 +04:00
|
|
|
pixman_region32_init_rect(region, INT32_MIN, INT32_MIN,
|
|
|
|
UINT32_MAX, UINT32_MAX);
|
2012-02-28 19:59:33 +04:00
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static struct weston_subsurface *
|
|
|
|
weston_surface_to_subsurface(struct weston_surface *surface);
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
WL_EXPORT struct weston_view *
|
|
|
|
weston_view_create(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_view *view;
|
|
|
|
|
2014-11-21 09:21:57 +03:00
|
|
|
view = zalloc(sizeof *view);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
view->surface = surface;
|
compositor: Assign new views to the primary plane
When we create a new view, assign it to the primary plane from the
beginning.
Currently, every view across the compositor will be assigned to a plane
during every repaint cycle of every output: the DRM renderer's
assign_planes hook will either move a view to a drm_plane, or to the
primary plane if a suitable drm_plane could not be found for the output
it is on. There are no other assign_planes implementation, and the
fallback when none is provided, is to assign every view to the primary
plane.
DRM's behaviour is undesirable in multi-output situations, since it
means that views which were on a plane on one output will be demoted to
the primary plane; doing this causes damage, which will cause a spurious
repaint for the output. This spurious repaint will have no effect on the
other output, but it will do the same demotion of views to the primary
plane, which will again provoke a repaint on the other output.
With a simple fix for this behaviour (i.e. not moving views which are
only visible on other outputs), the following behaviour is observed:
- outputs A and B are present
- views A and B are created for those outputs respectively, with SHM
buffers attached; view->plane == NULL for both
- current buffer content for views A and B are uploaded to the
renderer
- output A runs its repaint cycle, and sets keep_buffer to false on
surface B's output, as it can never be promoted to a plane; it does
not move view B to another plane
- output B runs its repaint cycle, and moves view B to the primary
plane
- weston_view_assign_to_plane has work to do (as the plane is changing
from NULL to the primary plane), calls weston_surface_damage and
calls weston_surface_damage
- weston_surface_damage re-uploads buffer content, possibly from
nowhere at all; e508ce6a notes that this behaviour is broken
Assigning views to the primary plane when created makes it possible to
fix the DRM assign_planes implementation: assign_planes will always set
keep_buffer to true if there is any chance the buffer can ever be
promoted to a plane, regardless of view configruation. If the buffer
cannot be promoted to a plane, it must by definition never migrate from
the primary plane. This means that there is no opportunity to hit the
same issue, where the buffer content has already been discarded, but
weston_view_assign_to_plane is not a no-op.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-12-09 19:27:54 +03:00
|
|
|
view->plane = &surface->compositor->primary_plane;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
/* Assign to surface */
|
|
|
|
wl_list_insert(&surface->views, &view->surface_link);
|
|
|
|
|
|
|
|
wl_signal_init(&view->destroy_signal);
|
|
|
|
wl_list_init(&view->link);
|
2014-07-09 23:12:56 +04:00
|
|
|
wl_list_init(&view->layer_link.link);
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_init(&view->paint_node_list);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
pixman_region32_init(&view->clip);
|
|
|
|
|
|
|
|
view->alpha = 1.0;
|
|
|
|
pixman_region32_init(&view->transform.opaque);
|
|
|
|
|
|
|
|
wl_list_init(&view->geometry.transformation_list);
|
|
|
|
wl_list_insert(&view->geometry.transformation_list,
|
|
|
|
&view->transform.position.link);
|
|
|
|
weston_matrix_init(&view->transform.position.matrix);
|
|
|
|
wl_list_init(&view->geometry.child_list);
|
2015-02-16 15:39:11 +03:00
|
|
|
pixman_region32_init(&view->geometry.scissor);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_init(&view->transform.boundingbox);
|
|
|
|
view->transform.dirty = 1;
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
struct weston_presentation_feedback {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
/* XXX: could use just wl_resource_get_link() instead */
|
|
|
|
struct wl_list link;
|
2014-12-17 17:20:41 +03:00
|
|
|
|
|
|
|
/* The per-surface feedback flags */
|
|
|
|
uint32_t psf_flags;
|
2014-09-24 06:08:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_presentation_feedback_discard(
|
|
|
|
struct weston_presentation_feedback *feedback)
|
|
|
|
{
|
2016-02-18 17:53:27 +03:00
|
|
|
wp_presentation_feedback_send_discarded(feedback->resource);
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_resource_destroy(feedback->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_presentation_feedback_discard_list(struct wl_list *list)
|
|
|
|
{
|
|
|
|
struct weston_presentation_feedback *feedback, *tmp;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(feedback, tmp, list, link)
|
|
|
|
weston_presentation_feedback_discard(feedback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_presentation_feedback_present(
|
|
|
|
struct weston_presentation_feedback *feedback,
|
|
|
|
struct weston_output *output,
|
|
|
|
uint32_t refresh_nsec,
|
|
|
|
const struct timespec *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
|
|
|
uint64_t seq,
|
|
|
|
uint32_t flags)
|
2014-09-24 06:08:46 +04:00
|
|
|
{
|
|
|
|
struct wl_client *client = wl_resource_get_client(feedback->resource);
|
2017-03-27 12:15:38 +03:00
|
|
|
struct weston_head *head;
|
2014-09-24 06:08:46 +04:00
|
|
|
struct wl_resource *o;
|
2017-12-13 14:27:54 +03:00
|
|
|
uint32_t tv_sec_hi;
|
|
|
|
uint32_t tv_sec_lo;
|
|
|
|
uint32_t tv_nsec;
|
2017-03-28 16:27:25 +03:00
|
|
|
bool done = false;
|
2014-09-24 06:08:46 +04:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
wl_resource_for_each(o, &head->resource_list) {
|
|
|
|
if (wl_resource_get_client(o) != client)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wp_presentation_feedback_send_sync_output(feedback->resource, o);
|
|
|
|
done = true;
|
|
|
|
}
|
2014-09-24 06:08:46 +04:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
/* For clone mode, send it for just one wl_output global,
|
|
|
|
* they are all equivalent anyway.
|
|
|
|
*/
|
|
|
|
if (done)
|
|
|
|
break;
|
2014-09-24 06:08:46 +04:00
|
|
|
}
|
|
|
|
|
2017-12-13 14:27:54 +03:00
|
|
|
timespec_to_proto(ts, &tv_sec_hi, &tv_sec_lo, &tv_nsec);
|
2016-02-18 17:53:27 +03:00
|
|
|
wp_presentation_feedback_send_presented(feedback->resource,
|
2017-12-13 14:27:54 +03:00
|
|
|
tv_sec_hi, tv_sec_lo, tv_nsec,
|
2016-02-18 17:53:27 +03:00
|
|
|
refresh_nsec,
|
|
|
|
seq >> 32, seq & 0xffffffff,
|
|
|
|
flags | feedback->psf_flags);
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_resource_destroy(feedback->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_presentation_feedback_present_list(struct wl_list *list,
|
|
|
|
struct weston_output *output,
|
|
|
|
uint32_t refresh_nsec,
|
|
|
|
const struct timespec *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
|
|
|
uint64_t seq,
|
|
|
|
uint32_t flags)
|
2014-09-24 06:08:46 +04:00
|
|
|
{
|
|
|
|
struct weston_presentation_feedback *feedback, *tmp;
|
|
|
|
|
2016-02-18 17:53:27 +03:00
|
|
|
assert(!(flags & WP_PRESENTATION_FEEDBACK_INVALID) ||
|
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
|
|
|
wl_list_empty(list));
|
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_list_for_each_safe(feedback, tmp, list, link)
|
|
|
|
weston_presentation_feedback_present(feedback, output,
|
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
|
|
|
refresh_nsec, ts, seq,
|
|
|
|
flags);
|
2014-09-24 06:08:46 +04:00
|
|
|
}
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
static void
|
|
|
|
surface_state_handle_buffer_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_surface_state *state =
|
|
|
|
container_of(listener, struct weston_surface_state,
|
|
|
|
buffer_destroy_listener);
|
|
|
|
|
|
|
|
state->buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_state_init(struct weston_surface_state *state)
|
|
|
|
{
|
|
|
|
state->newly_attached = 0;
|
|
|
|
state->buffer = NULL;
|
|
|
|
state->buffer_destroy_listener.notify =
|
|
|
|
surface_state_handle_buffer_destroy;
|
|
|
|
state->sx = 0;
|
|
|
|
state->sy = 0;
|
|
|
|
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_init(&state->damage_surface);
|
|
|
|
pixman_region32_init(&state->damage_buffer);
|
2014-05-20 23:33:03 +04:00
|
|
|
pixman_region32_init(&state->opaque);
|
|
|
|
region_init_infinite(&state->input);
|
|
|
|
|
|
|
|
wl_list_init(&state->frame_callback_list);
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_list_init(&state->feedback_list);
|
2014-05-20 23:33:03 +04:00
|
|
|
|
|
|
|
state->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
state->buffer_viewport.buffer.scale = 1;
|
|
|
|
state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
|
|
|
|
state->buffer_viewport.surface.width = -1;
|
|
|
|
state->buffer_viewport.changed = 0;
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
|
|
|
|
state->acquire_fence_fd = -1;
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
|
|
|
|
state->desired_protection = WESTON_HDCP_DISABLE;
|
2019-03-28 12:35:42 +03:00
|
|
|
state->protection_mode = WESTON_SURFACE_PROTECTION_MODE_RELAXED;
|
2014-05-20 23:33:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_state_fini(struct weston_surface_state *state)
|
|
|
|
{
|
2021-07-29 11:16:51 +03:00
|
|
|
struct wl_resource *cb, *next;
|
2014-05-20 23:33:03 +04:00
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_resource_for_each_safe(cb, next, &state->frame_callback_list)
|
|
|
|
wl_resource_destroy(cb);
|
2014-05-20 23:33:03 +04:00
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
weston_presentation_feedback_discard_list(&state->feedback_list);
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
pixman_region32_fini(&state->input);
|
|
|
|
pixman_region32_fini(&state->opaque);
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_fini(&state->damage_surface);
|
|
|
|
pixman_region32_fini(&state->damage_buffer);
|
2014-05-20 23:33:03 +04:00
|
|
|
|
|
|
|
if (state->buffer)
|
|
|
|
wl_list_remove(&state->buffer_destroy_listener.link);
|
|
|
|
state->buffer = NULL;
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
|
|
|
|
fd_clear(&state->acquire_fence_fd);
|
2018-10-19 12:14:11 +03:00
|
|
|
weston_buffer_release_reference(&state->buffer_release_ref, NULL);
|
2014-05-20 23:33:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_state_set_buffer(struct weston_surface_state *state,
|
|
|
|
struct weston_buffer *buffer)
|
|
|
|
{
|
|
|
|
if (state->buffer == buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (state->buffer)
|
|
|
|
wl_list_remove(&state->buffer_destroy_listener.link);
|
|
|
|
state->buffer = buffer;
|
|
|
|
if (state->buffer)
|
|
|
|
wl_signal_add(&state->buffer->destroy_signal,
|
|
|
|
&state->buffer_destroy_listener);
|
|
|
|
}
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
WL_EXPORT struct weston_surface *
|
2012-01-27 20:58:31 +04:00
|
|
|
weston_surface_create(struct weston_compositor *compositor)
|
2009-02-10 22:20:26 +03:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_surface *surface;
|
2010-08-16 18:38:29 +04:00
|
|
|
|
2014-11-21 09:21:57 +03:00
|
|
|
surface = zalloc(sizeof *surface);
|
2010-08-16 18:38:29 +04:00
|
|
|
if (surface == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-07 07:34:41 +04:00
|
|
|
wl_signal_init(&surface->destroy_signal);
|
2016-07-22 12:48:03 +03:00
|
|
|
wl_signal_init(&surface->commit_signal);
|
2013-06-07 07:34:41 +04:00
|
|
|
|
2009-02-10 22:20:26 +03:00
|
|
|
surface->compositor = compositor;
|
2013-08-14 01:10:14 +04:00
|
|
|
surface->ref_count = 1;
|
2010-06-07 06:23:21 +04:00
|
|
|
|
2014-03-14 16:38:15 +04:00
|
|
|
surface->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
surface->buffer_viewport.buffer.scale = 1;
|
2014-03-14 16:38:16 +04:00
|
|
|
surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
|
|
|
|
surface->buffer_viewport.surface.width = -1;
|
2014-05-20 23:33:03 +04:00
|
|
|
|
|
|
|
weston_surface_state_init(&surface->pending);
|
|
|
|
|
2011-06-24 04:29:12 +04:00
|
|
|
pixman_region32_init(&surface->damage);
|
2012-02-24 01:11:59 +04:00
|
|
|
pixman_region32_init(&surface->opaque);
|
2012-10-10 13:49:32 +04:00
|
|
|
region_init_infinite(&surface->input);
|
2011-06-24 04:29:12 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_init(&surface->views);
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_init(&surface->paint_node_list);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
wl_list_init(&surface->frame_callback_list);
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_list_init(&surface->feedback_list);
|
2008-11-24 01:07:32 +03:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
wl_list_init(&surface->subsurface_list);
|
|
|
|
wl_list_init(&surface->subsurface_list_pending);
|
|
|
|
|
2014-10-16 19:55:19 +04:00
|
|
|
weston_matrix_init(&surface->buffer_to_surface_matrix);
|
|
|
|
weston_matrix_init(&surface->surface_to_buffer_matrix);
|
|
|
|
|
2016-07-22 12:56:31 +03:00
|
|
|
wl_list_init(&surface->pointer_constraints);
|
|
|
|
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
surface->acquire_fence_fd = -1;
|
|
|
|
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
surface->desired_protection = WESTON_HDCP_DISABLE;
|
2019-03-28 12:35:42 +03:00
|
|
|
surface->current_protection = WESTON_HDCP_DISABLE;
|
|
|
|
surface->protection_mode = WESTON_SURFACE_PROTECTION_MODE_RELAXED;
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
|
2010-08-16 18:38:29 +04:00
|
|
|
return surface;
|
2008-11-24 01:07:32 +03:00
|
|
|
}
|
|
|
|
|
2012-06-18 21:17:32 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_to_global_float(struct weston_view *view,
|
|
|
|
float sx, float sy, float *x, float *y)
|
2012-02-08 17:23:15 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->transform.enabled) {
|
2012-02-08 17:23:15 +04:00
|
|
|
struct weston_vector v = { { sx, sy, 0.0f, 1.0f } };
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_matrix_transform(&view->transform.matrix, &v);
|
2012-02-08 17:23:15 +04:00
|
|
|
|
|
|
|
if (fabsf(v.f[3]) < 1e-6) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("warning: numerical instability in "
|
2013-02-11 15:45:38 +04:00
|
|
|
"%s(), divisor = %g\n", __func__,
|
2012-02-08 17:23:15 +04:00
|
|
|
v.f[3]);
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*x = v.f[0] / v.f[3];
|
|
|
|
*y = v.f[1] / v.f[3];
|
|
|
|
} else {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
*x = sx + view->geometry.x;
|
|
|
|
*y = sy + view->geometry.y;
|
2012-02-08 17:23:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:50:03 +03:00
|
|
|
/** Transform a point to buffer coordinates
|
|
|
|
*
|
|
|
|
* \param width Surface width.
|
|
|
|
* \param height Surface height.
|
|
|
|
* \param transform Buffer transform.
|
|
|
|
* \param scale Buffer scale.
|
|
|
|
* \param sx Surface x coordinate of a point.
|
|
|
|
* \param sy Surface y coordinate of a point.
|
|
|
|
* \param[out] bx Buffer x coordinate of the point.
|
|
|
|
* \param[out] by Buffer Y coordinate of the point.
|
|
|
|
*
|
|
|
|
* Converts the given surface-local coordinates to buffer coordinates
|
|
|
|
* according to the given buffer transform and scale.
|
|
|
|
* This ignores wp_viewport.
|
|
|
|
*
|
|
|
|
* The given width and height must be the result of inverse scaled and
|
|
|
|
* inverse transformed buffer size.
|
|
|
|
*/
|
2013-02-21 20:35:16 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_transformed_coord(int width, int height,
|
|
|
|
enum wl_output_transform transform,
|
2013-05-24 15:09:43 +04:00
|
|
|
int32_t scale,
|
2013-02-21 20:35:16 +04:00
|
|
|
float sx, float sy, float *bx, float *by)
|
|
|
|
{
|
|
|
|
switch (transform) {
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
default:
|
|
|
|
*bx = sx;
|
|
|
|
*by = sy;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
*bx = width - sx;
|
|
|
|
*by = sy;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
*bx = sy;
|
|
|
|
*by = width - sx;
|
2013-02-21 20:35:16 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
*bx = sy;
|
|
|
|
*by = sx;
|
2013-02-21 20:35:16 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
*bx = width - sx;
|
|
|
|
*by = height - sy;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
*bx = sx;
|
|
|
|
*by = height - sy;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
*bx = height - sy;
|
|
|
|
*by = sx;
|
2013-02-21 20:35:16 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
*bx = height - sy;
|
|
|
|
*by = width - sx;
|
2013-02-21 20:35:16 +04:00
|
|
|
break;
|
|
|
|
}
|
2013-05-22 16:41:37 +04:00
|
|
|
|
|
|
|
*bx *= scale;
|
|
|
|
*by *= scale;
|
2013-02-21 20:35:16 +04:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:50:03 +03:00
|
|
|
/** Transform a rectangle to buffer coordinates
|
|
|
|
*
|
|
|
|
* \param width Surface width.
|
|
|
|
* \param height Surface height.
|
|
|
|
* \param transform Buffer transform.
|
|
|
|
* \param scale Buffer scale.
|
|
|
|
* \param rect Rectangle in surface coordinates.
|
|
|
|
* \return Rectangle in buffer coordinates.
|
|
|
|
*
|
|
|
|
* Converts the given surface-local rectangle to buffer coordinates
|
|
|
|
* according to the given buffer transform and scale. The resulting
|
|
|
|
* rectangle is guaranteed to be well-formed.
|
|
|
|
* This ignores wp_viewport.
|
|
|
|
*
|
|
|
|
* The given width and height must be the result of inverse scaled and
|
|
|
|
* inverse transformed buffer size.
|
|
|
|
*/
|
2013-02-21 20:35:16 +04:00
|
|
|
WL_EXPORT pixman_box32_t
|
|
|
|
weston_transformed_rect(int width, int height,
|
|
|
|
enum wl_output_transform transform,
|
2013-05-24 15:09:43 +04:00
|
|
|
int32_t scale,
|
2013-02-21 20:35:16 +04:00
|
|
|
pixman_box32_t rect)
|
|
|
|
{
|
|
|
|
float x1, x2, y1, y2;
|
|
|
|
|
|
|
|
pixman_box32_t ret;
|
|
|
|
|
2013-05-22 16:41:37 +04:00
|
|
|
weston_transformed_coord(width, height, transform, scale,
|
2013-02-21 20:35:16 +04:00
|
|
|
rect.x1, rect.y1, &x1, &y1);
|
2013-05-22 16:41:37 +04:00
|
|
|
weston_transformed_coord(width, height, transform, scale,
|
2013-02-21 20:35:16 +04:00
|
|
|
rect.x2, rect.y2, &x2, &y2);
|
|
|
|
|
|
|
|
if (x1 <= x2) {
|
|
|
|
ret.x1 = x1;
|
|
|
|
ret.x2 = x2;
|
|
|
|
} else {
|
|
|
|
ret.x1 = x2;
|
|
|
|
ret.x2 = x1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y1 <= y2) {
|
|
|
|
ret.y1 = y1;
|
|
|
|
ret.y2 = y2;
|
|
|
|
} else {
|
|
|
|
ret.y1 = y2;
|
|
|
|
ret.y2 = y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-19 01:32:30 +03:00
|
|
|
/** Transform a region by a matrix, restricted to axis-aligned transformations
|
|
|
|
*
|
|
|
|
* Warning: This function does not work for projective, affine, or matrices
|
|
|
|
* that encode arbitrary rotations. Only 90-degree step rotations are
|
|
|
|
* supported.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_matrix_transform_region(pixman_region32_t *dest,
|
|
|
|
struct weston_matrix *matrix,
|
|
|
|
pixman_region32_t *src)
|
|
|
|
{
|
|
|
|
pixman_box32_t *src_rects, *dest_rects;
|
|
|
|
int nrects, i;
|
|
|
|
|
|
|
|
src_rects = pixman_region32_rectangles(src, &nrects);
|
|
|
|
dest_rects = malloc(nrects * sizeof(*dest_rects));
|
|
|
|
if (!dest_rects)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < nrects; i++) {
|
|
|
|
struct weston_vector vec1 = {{
|
|
|
|
src_rects[i].x1, src_rects[i].y1, 0, 1
|
|
|
|
}};
|
|
|
|
weston_matrix_transform(matrix, &vec1);
|
|
|
|
vec1.f[0] /= vec1.f[3];
|
|
|
|
vec1.f[1] /= vec1.f[3];
|
|
|
|
|
|
|
|
struct weston_vector vec2 = {{
|
|
|
|
src_rects[i].x2, src_rects[i].y2, 0, 1
|
|
|
|
}};
|
|
|
|
weston_matrix_transform(matrix, &vec2);
|
|
|
|
vec2.f[0] /= vec2.f[3];
|
|
|
|
vec2.f[1] /= vec2.f[3];
|
|
|
|
|
|
|
|
if (vec1.f[0] < vec2.f[0]) {
|
|
|
|
dest_rects[i].x1 = floor(vec1.f[0]);
|
|
|
|
dest_rects[i].x2 = ceil(vec2.f[0]);
|
|
|
|
} else {
|
|
|
|
dest_rects[i].x1 = floor(vec2.f[0]);
|
|
|
|
dest_rects[i].x2 = ceil(vec1.f[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vec1.f[1] < vec2.f[1]) {
|
|
|
|
dest_rects[i].y1 = floor(vec1.f[1]);
|
|
|
|
dest_rects[i].y2 = ceil(vec2.f[1]);
|
|
|
|
} else {
|
|
|
|
dest_rects[i].y1 = floor(vec2.f[1]);
|
|
|
|
dest_rects[i].y2 = ceil(vec1.f[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_clear(dest);
|
|
|
|
pixman_region32_init_rects(dest, dest_rects, nrects);
|
|
|
|
free(dest_rects);
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:50:03 +03:00
|
|
|
/** Transform a region to buffer coordinates
|
|
|
|
*
|
|
|
|
* \param width Surface width.
|
|
|
|
* \param height Surface height.
|
|
|
|
* \param transform Buffer transform.
|
|
|
|
* \param scale Buffer scale.
|
|
|
|
* \param[in] src Region in surface coordinates.
|
|
|
|
* \param[out] dest Resulting region in buffer coordinates.
|
|
|
|
*
|
|
|
|
* Converts the given surface-local region to buffer coordinates
|
|
|
|
* according to the given buffer transform and scale.
|
|
|
|
* This ignores wp_viewport.
|
|
|
|
*
|
|
|
|
* The given width and height must be the result of inverse scaled and
|
|
|
|
* inverse transformed buffer size.
|
|
|
|
*
|
|
|
|
* src and dest are allowed to point to the same memory for in-place conversion.
|
|
|
|
*/
|
2013-10-28 07:25:01 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_transformed_region(int width, int height,
|
|
|
|
enum wl_output_transform transform,
|
|
|
|
int32_t scale,
|
|
|
|
pixman_region32_t *src, pixman_region32_t *dest)
|
|
|
|
{
|
|
|
|
pixman_box32_t *src_rects, *dest_rects;
|
|
|
|
int nrects, i;
|
|
|
|
|
|
|
|
if (transform == WL_OUTPUT_TRANSFORM_NORMAL && scale == 1) {
|
|
|
|
if (src != dest)
|
|
|
|
pixman_region32_copy(dest, src);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
src_rects = pixman_region32_rectangles(src, &nrects);
|
|
|
|
dest_rects = malloc(nrects * sizeof(*dest_rects));
|
|
|
|
if (!dest_rects)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (transform == WL_OUTPUT_TRANSFORM_NORMAL) {
|
|
|
|
memcpy(dest_rects, src_rects, nrects * sizeof(*dest_rects));
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < nrects; i++) {
|
|
|
|
switch (transform) {
|
|
|
|
default:
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
dest_rects[i].x1 = src_rects[i].x1;
|
|
|
|
dest_rects[i].y1 = src_rects[i].y1;
|
|
|
|
dest_rects[i].x2 = src_rects[i].x2;
|
|
|
|
dest_rects[i].y2 = src_rects[i].y2;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
dest_rects[i].x1 = src_rects[i].y1;
|
|
|
|
dest_rects[i].y1 = width - src_rects[i].x2;
|
|
|
|
dest_rects[i].x2 = src_rects[i].y2;
|
|
|
|
dest_rects[i].y2 = width - src_rects[i].x1;
|
2013-10-28 07:25:01 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
dest_rects[i].x1 = width - src_rects[i].x2;
|
|
|
|
dest_rects[i].y1 = height - src_rects[i].y2;
|
|
|
|
dest_rects[i].x2 = width - src_rects[i].x1;
|
|
|
|
dest_rects[i].y2 = height - src_rects[i].y1;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
dest_rects[i].x1 = height - src_rects[i].y2;
|
|
|
|
dest_rects[i].y1 = src_rects[i].x1;
|
|
|
|
dest_rects[i].x2 = height - src_rects[i].y1;
|
|
|
|
dest_rects[i].y2 = src_rects[i].x2;
|
2013-10-28 07:25:01 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
dest_rects[i].x1 = width - src_rects[i].x2;
|
|
|
|
dest_rects[i].y1 = src_rects[i].y1;
|
|
|
|
dest_rects[i].x2 = width - src_rects[i].x1;
|
|
|
|
dest_rects[i].y2 = src_rects[i].y2;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
dest_rects[i].x1 = src_rects[i].y1;
|
|
|
|
dest_rects[i].y1 = src_rects[i].x1;
|
|
|
|
dest_rects[i].x2 = src_rects[i].y2;
|
|
|
|
dest_rects[i].y2 = src_rects[i].x2;
|
2013-10-28 07:25:01 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
dest_rects[i].x1 = src_rects[i].x1;
|
|
|
|
dest_rects[i].y1 = height - src_rects[i].y2;
|
|
|
|
dest_rects[i].x2 = src_rects[i].x2;
|
|
|
|
dest_rects[i].y2 = height - src_rects[i].y1;
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
dest_rects[i].x1 = height - src_rects[i].y2;
|
|
|
|
dest_rects[i].y1 = width - src_rects[i].x2;
|
|
|
|
dest_rects[i].x2 = height - src_rects[i].y1;
|
|
|
|
dest_rects[i].y2 = width - src_rects[i].x1;
|
2013-10-28 07:25:01 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scale != 1) {
|
|
|
|
for (i = 0; i < nrects; i++) {
|
|
|
|
dest_rects[i].x1 *= scale;
|
|
|
|
dest_rects[i].x2 *= scale;
|
|
|
|
dest_rects[i].y1 *= scale;
|
|
|
|
dest_rects[i].y2 *= scale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_clear(dest);
|
|
|
|
pixman_region32_init_rects(dest, dest_rects, nrects);
|
|
|
|
free(dest_rects);
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:19:46 +04:00
|
|
|
static void
|
2016-04-15 16:42:49 +03:00
|
|
|
viewport_surface_to_buffer(struct weston_surface *surface,
|
|
|
|
float sx, float sy, float *bx, float *by)
|
2013-11-26 21:19:46 +04:00
|
|
|
{
|
2014-03-14 16:38:15 +04:00
|
|
|
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
2014-03-14 16:38:17 +04:00
|
|
|
double src_width, src_height;
|
|
|
|
double src_x, src_y;
|
2014-03-14 16:38:15 +04:00
|
|
|
|
2014-03-14 16:38:17 +04:00
|
|
|
if (vp->buffer.src_width == wl_fixed_from_int(-1)) {
|
|
|
|
if (vp->surface.width == -1) {
|
|
|
|
*bx = sx;
|
|
|
|
*by = sy;
|
|
|
|
return;
|
|
|
|
}
|
2013-11-26 21:19:46 +04:00
|
|
|
|
2014-03-14 16:38:17 +04:00
|
|
|
src_x = 0.0;
|
|
|
|
src_y = 0.0;
|
|
|
|
src_width = surface->width_from_buffer;
|
|
|
|
src_height = surface->height_from_buffer;
|
2013-11-26 21:19:46 +04:00
|
|
|
} else {
|
2014-03-14 16:38:17 +04:00
|
|
|
src_x = wl_fixed_to_double(vp->buffer.src_x);
|
|
|
|
src_y = wl_fixed_to_double(vp->buffer.src_y);
|
|
|
|
src_width = wl_fixed_to_double(vp->buffer.src_width);
|
|
|
|
src_height = wl_fixed_to_double(vp->buffer.src_height);
|
2013-11-26 21:19:46 +04:00
|
|
|
}
|
2014-03-14 16:38:17 +04:00
|
|
|
|
|
|
|
*bx = sx * src_width / surface->width + src_x;
|
|
|
|
*by = sy * src_height / surface->height + src_y;
|
2013-11-26 21:19:46 +04:00
|
|
|
}
|
|
|
|
|
2012-11-28 19:10:26 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_to_buffer_float(struct weston_surface *surface,
|
|
|
|
float sx, float sy, float *bx, float *by)
|
|
|
|
{
|
2014-03-14 16:38:15 +04:00
|
|
|
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
|
|
|
|
2016-04-15 16:42:49 +03:00
|
|
|
/* first transform coordinates if the viewport is set */
|
|
|
|
viewport_surface_to_buffer(surface, sx, sy, bx, by);
|
2013-11-26 21:19:46 +04:00
|
|
|
|
2014-04-22 05:56:46 +04:00
|
|
|
weston_transformed_coord(surface->width_from_buffer,
|
|
|
|
surface->height_from_buffer,
|
2014-03-14 16:38:15 +04:00
|
|
|
vp->buffer.transform, vp->buffer.scale,
|
2013-11-26 21:19:46 +04:00
|
|
|
*bx, *by, bx, by);
|
2012-11-28 19:10:26 +04:00
|
|
|
}
|
|
|
|
|
2015-12-04 01:38:11 +03:00
|
|
|
/** Transform a rectangle from surface coordinates to buffer coordinates
|
|
|
|
*
|
2016-04-15 14:47:08 +03:00
|
|
|
* \param surface The surface to fetch wp_viewport and buffer transformation
|
2015-12-04 01:38:11 +03:00
|
|
|
* from.
|
|
|
|
* \param rect The rectangle to transform.
|
|
|
|
* \return The transformed rectangle.
|
|
|
|
*
|
|
|
|
* Viewport and buffer transformations can only do translation, scaling,
|
|
|
|
* and rotations in 90-degree steps. Therefore the only loss in the
|
|
|
|
* conversion is coordinate rounding.
|
|
|
|
*
|
|
|
|
* However, some coordinate rounding takes place as an intermediate
|
|
|
|
* step before the buffer scale factor is applied, so the rectangle
|
|
|
|
* boundary may not be exactly as expected.
|
|
|
|
*
|
|
|
|
* This is OK for damage tracking since a little extra coverage is
|
|
|
|
* not a problem.
|
|
|
|
*/
|
2012-11-28 19:10:26 +04:00
|
|
|
WL_EXPORT pixman_box32_t
|
|
|
|
weston_surface_to_buffer_rect(struct weston_surface *surface,
|
|
|
|
pixman_box32_t rect)
|
|
|
|
{
|
2014-03-14 16:38:15 +04:00
|
|
|
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
2013-11-26 21:19:46 +04:00
|
|
|
float xf, yf;
|
|
|
|
|
2016-04-15 16:42:49 +03:00
|
|
|
/* first transform box coordinates if the viewport is set */
|
|
|
|
viewport_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
|
2013-11-26 21:19:46 +04:00
|
|
|
rect.x1 = floorf(xf);
|
|
|
|
rect.y1 = floorf(yf);
|
|
|
|
|
2016-04-15 16:42:49 +03:00
|
|
|
viewport_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
|
2015-12-01 22:00:43 +03:00
|
|
|
rect.x2 = ceilf(xf);
|
|
|
|
rect.y2 = ceilf(yf);
|
2013-11-26 21:19:46 +04:00
|
|
|
|
2014-04-22 05:56:46 +04:00
|
|
|
return weston_transformed_rect(surface->width_from_buffer,
|
|
|
|
surface->height_from_buffer,
|
2014-03-14 16:38:15 +04:00
|
|
|
vp->buffer.transform, vp->buffer.scale,
|
2013-05-22 16:41:37 +04:00
|
|
|
rect);
|
2012-11-28 19:10:26 +04:00
|
|
|
}
|
|
|
|
|
2015-03-04 15:23:28 +03:00
|
|
|
/** Transform a region from surface coordinates to buffer coordinates
|
|
|
|
*
|
2016-04-15 14:47:08 +03:00
|
|
|
* \param surface The surface to fetch wp_viewport and buffer transformation
|
2015-03-04 15:23:28 +03:00
|
|
|
* from.
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param[in] surface_region The region in surface coordinates.
|
|
|
|
* \param[out] buffer_region The region converted to buffer coordinates.
|
2015-03-04 15:23:28 +03:00
|
|
|
*
|
|
|
|
* Buffer_region must be init'd, but will be completely overwritten.
|
|
|
|
*
|
|
|
|
* Viewport and buffer transformations can only do translation, scaling,
|
|
|
|
* and rotations in 90-degree steps. Therefore the only loss in the
|
2015-12-04 01:38:11 +03:00
|
|
|
* conversion is from the coordinate rounding that takes place in
|
|
|
|
* \ref weston_surface_to_buffer_rect.
|
2019-06-12 16:05:44 +03:00
|
|
|
*
|
2015-03-04 15:23:28 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_to_buffer_region(struct weston_surface *surface,
|
|
|
|
pixman_region32_t *surface_region,
|
|
|
|
pixman_region32_t *buffer_region)
|
|
|
|
{
|
|
|
|
pixman_box32_t *src_rects, *dest_rects;
|
|
|
|
int nrects, i;
|
|
|
|
|
|
|
|
src_rects = pixman_region32_rectangles(surface_region, &nrects);
|
|
|
|
dest_rects = malloc(nrects * sizeof(*dest_rects));
|
|
|
|
if (!dest_rects)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < nrects; i++) {
|
|
|
|
dest_rects[i] = weston_surface_to_buffer_rect(surface,
|
|
|
|
src_rects[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_fini(buffer_region);
|
|
|
|
pixman_region32_init_rects(buffer_region, dest_rects, nrects);
|
|
|
|
free(dest_rects);
|
|
|
|
}
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_move_to_plane(struct weston_view *view,
|
2012-08-03 19:30:18 +04:00
|
|
|
struct weston_plane *plane)
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->plane == plane)
|
2012-08-03 19:30:18 +04:00
|
|
|
return;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_damage_below(view);
|
|
|
|
view->plane = plane;
|
|
|
|
weston_surface_damage(view->surface);
|
2012-08-03 19:30:18 +04:00
|
|
|
}
|
|
|
|
|
2015-02-17 14:10:01 +03:00
|
|
|
/** Inflict damage on the plane where the view is visible.
|
|
|
|
*
|
|
|
|
* \param view The view that causes the damage.
|
|
|
|
*
|
|
|
|
* If the view is currently on a plane (including the primary plane),
|
|
|
|
* take the view's boundingbox, subtract all the opaque views that cover it,
|
|
|
|
* and add the remaining region as damage to the plane. This corresponds
|
|
|
|
* to the damage inflicted to the plane if this view disappeared.
|
|
|
|
*
|
|
|
|
* A repaint is scheduled for this view.
|
|
|
|
*
|
|
|
|
* The region of all opaque views covering this view is stored in
|
|
|
|
* weston_view::clip and updated by view_accumulate_damage() during
|
|
|
|
* weston_output_repaint(). Specifically, that region matches the
|
|
|
|
* scenegraph as it was last painted.
|
|
|
|
*/
|
2012-02-24 08:03:14 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_damage_below(struct weston_view *view)
|
2012-02-08 16:49:37 +04:00
|
|
|
{
|
2012-02-29 07:47:14 +04:00
|
|
|
pixman_region32_t damage;
|
|
|
|
|
|
|
|
pixman_region32_init(&damage);
|
2015-02-19 12:15:33 +03:00
|
|
|
pixman_region32_subtract(&damage, &view->transform.boundingbox,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
&view->clip);
|
2013-10-23 09:58:31 +04:00
|
|
|
if (view->plane)
|
|
|
|
pixman_region32_union(&view->plane->damage,
|
|
|
|
&view->plane->damage, &damage);
|
2012-02-29 07:47:14 +04:00
|
|
|
pixman_region32_fini(&damage);
|
2013-11-14 09:33:43 +04:00
|
|
|
weston_view_schedule_repaint(view);
|
2012-02-08 16:49:37 +04:00
|
|
|
}
|
|
|
|
|
2017-03-24 17:21:06 +03:00
|
|
|
/** Send wl_surface.enter/leave events
|
|
|
|
*
|
|
|
|
* \param surface The surface.
|
2017-03-27 12:15:38 +03:00
|
|
|
* \param head A head of the entered/left output.
|
2017-03-24 17:21:06 +03:00
|
|
|
* \param enter True if entered.
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param leave True if left.
|
2017-03-24 17:21:06 +03:00
|
|
|
*
|
|
|
|
* Send the enter/leave events for all protocol objects bound to the given
|
|
|
|
* output by the client owning the surface.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_surface_send_enter_leave(struct weston_surface *surface,
|
2017-03-27 12:15:38 +03:00
|
|
|
struct weston_head *head,
|
2017-03-24 17:21:06 +03:00
|
|
|
bool enter,
|
|
|
|
bool leave)
|
|
|
|
{
|
|
|
|
struct wl_resource *wloutput;
|
|
|
|
struct wl_client *client;
|
|
|
|
|
|
|
|
assert(enter != leave);
|
|
|
|
|
|
|
|
client = wl_resource_get_client(surface->resource);
|
2017-03-27 12:15:38 +03:00
|
|
|
wl_resource_for_each(wloutput, &head->resource_list) {
|
2017-03-24 17:21:06 +03:00
|
|
|
if (wl_resource_get_client(wloutput) != client)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (enter)
|
|
|
|
wl_surface_send_enter(surface->resource, wloutput);
|
|
|
|
if (leave)
|
|
|
|
wl_surface_send_leave(surface->resource, wloutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:51:58 +03:00
|
|
|
static void
|
|
|
|
weston_surface_compute_protection(struct protected_surface *psurface)
|
|
|
|
{
|
|
|
|
enum weston_hdcp_protection min_protection;
|
|
|
|
bool min_protection_valid = false;
|
|
|
|
struct weston_surface *surface = psurface->surface;
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &surface->compositor->output_list, link)
|
|
|
|
if (surface->output_mask & (1u << output->id)) {
|
2019-07-08 12:42:19 +03:00
|
|
|
/*
|
|
|
|
* If the content-protection is enabled with protection
|
|
|
|
* mode as RELAXED for a surface, and if
|
|
|
|
* content-recording features like: screen-shooter,
|
|
|
|
* recorder, screen-sharing, etc are on, then notify the
|
|
|
|
* client, that the protection is disabled.
|
|
|
|
*
|
|
|
|
* Note: If the protection mode is ENFORCED then there
|
|
|
|
* is no need to bother the client as the renderer takes
|
|
|
|
* care of censoring the visibility of the protected
|
|
|
|
* content.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (output->disable_planes > 0 &&
|
|
|
|
surface->protection_mode == WESTON_SURFACE_PROTECTION_MODE_RELAXED) {
|
|
|
|
min_protection = WESTON_HDCP_DISABLE;
|
|
|
|
min_protection_valid = true;
|
|
|
|
break;
|
|
|
|
}
|
2019-04-03 16:51:58 +03:00
|
|
|
if (!min_protection_valid) {
|
|
|
|
min_protection = output->current_protection;
|
|
|
|
min_protection_valid = true;
|
|
|
|
}
|
|
|
|
if (output->current_protection < min_protection)
|
|
|
|
min_protection = output->current_protection;
|
|
|
|
}
|
|
|
|
if (!min_protection_valid)
|
|
|
|
min_protection = WESTON_HDCP_DISABLE;
|
|
|
|
|
|
|
|
surface->current_protection = min_protection;
|
2019-07-08 12:42:19 +03:00
|
|
|
|
|
|
|
weston_protected_surface_send_event(psurface, surface->current_protection);
|
2019-04-03 16:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notify_surface_protection_change(void *data)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
struct content_protection *cp;
|
|
|
|
struct protected_surface *psurface;
|
|
|
|
|
|
|
|
cp = compositor->content_protection;
|
|
|
|
cp->surface_protection_update = NULL;
|
|
|
|
|
|
|
|
/* Notify the clients, whose surfaces are changed */
|
|
|
|
wl_list_for_each(psurface, &cp->protected_list, link)
|
|
|
|
if (psurface && psurface->surface)
|
|
|
|
weston_surface_compute_protection(psurface);
|
|
|
|
}
|
|
|
|
|
2019-07-08 10:53:24 +03:00
|
|
|
/**
|
|
|
|
* \param compositor weston_compositor
|
|
|
|
*
|
|
|
|
* Schedule an idle task to notify surface about the update in protection,
|
|
|
|
* if not already scheduled.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_schedule_surface_protection_update(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct content_protection *cp = compositor->content_protection;
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
|
|
|
|
if (!cp || cp->surface_protection_update)
|
|
|
|
return;
|
|
|
|
loop = wl_display_get_event_loop(compositor->wl_display);
|
|
|
|
cp->surface_protection_update = wl_event_loop_add_idle(loop,
|
|
|
|
notify_surface_protection_change,
|
|
|
|
compositor);
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:01:58 +03:00
|
|
|
/**
|
|
|
|
* \param es The surface
|
|
|
|
* \param mask The new set of outputs for the surface
|
|
|
|
*
|
|
|
|
* Sets the surface's set of outputs to the ones specified by
|
|
|
|
* the new output mask provided. Identifies the outputs that
|
|
|
|
* have changed, the posts enter and leave events for these
|
|
|
|
* outputs as appropriate.
|
|
|
|
*/
|
2012-09-25 22:48:04 +04:00
|
|
|
static void
|
|
|
|
weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
|
|
|
|
{
|
|
|
|
uint32_t different = es->output_mask ^ mask;
|
|
|
|
uint32_t entered = mask & different;
|
|
|
|
uint32_t left = es->output_mask & different;
|
2017-03-24 17:21:06 +03:00
|
|
|
uint32_t output_bit;
|
2012-09-25 22:48:04 +04:00
|
|
|
struct weston_output *output;
|
2017-03-28 16:27:25 +03:00
|
|
|
struct weston_head *head;
|
2012-09-25 22:48:04 +04:00
|
|
|
|
|
|
|
es->output_mask = mask;
|
2013-06-07 07:34:41 +04:00
|
|
|
if (es->resource == NULL)
|
2012-09-25 22:48:04 +04:00
|
|
|
return;
|
|
|
|
if (different == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &es->compositor->output_list, link) {
|
2017-03-24 17:21:06 +03:00
|
|
|
output_bit = 1u << output->id;
|
|
|
|
if (!(output_bit & different))
|
2012-09-25 22:48:04 +04:00
|
|
|
continue;
|
2017-03-24 17:21:06 +03:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
weston_surface_send_enter_leave(es, head,
|
|
|
|
output_bit & entered,
|
|
|
|
output_bit & left);
|
|
|
|
}
|
2012-09-25 22:48:04 +04:00
|
|
|
}
|
2019-04-03 16:51:58 +03:00
|
|
|
/*
|
|
|
|
* Change in surfaces' output mask might trigger a change in its
|
|
|
|
* protection.
|
|
|
|
*/
|
2019-07-08 10:53:24 +03:00
|
|
|
weston_schedule_surface_protection_update(es->compositor);
|
2012-09-25 22:48:04 +04:00
|
|
|
}
|
|
|
|
|
2018-04-26 12:08:10 +03:00
|
|
|
static void
|
|
|
|
notify_view_output_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_view *view =
|
|
|
|
container_of(listener,
|
|
|
|
struct weston_view, output_destroy_listener);
|
|
|
|
|
|
|
|
view->output = NULL;
|
|
|
|
view->output_destroy_listener.notify = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the primary output of the view
|
|
|
|
*
|
|
|
|
* \param view The view whose primary output to set
|
|
|
|
* \param output The new primary output for the view
|
|
|
|
*
|
|
|
|
* Set \a output to be the primary output of the \a view.
|
|
|
|
*
|
|
|
|
* Notice that the assignment may be temporary; the primary output could be
|
|
|
|
* automatically changed. Hence, one cannot rely on the value persisting.
|
|
|
|
*
|
|
|
|
* Passing NULL as /a output will set the primary output to NULL.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_view_set_output(struct weston_view *view, struct weston_output *output)
|
|
|
|
{
|
|
|
|
if (view->output_destroy_listener.notify) {
|
|
|
|
wl_list_remove(&view->output_destroy_listener.link);
|
|
|
|
view->output_destroy_listener.notify = NULL;
|
|
|
|
}
|
|
|
|
view->output = output;
|
|
|
|
if (output) {
|
|
|
|
view->output_destroy_listener.notify =
|
|
|
|
notify_view_output_destroy;
|
|
|
|
wl_signal_add(&output->destroy_signal,
|
|
|
|
&view->output_destroy_listener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:01:58 +03:00
|
|
|
/** Recalculate which output(s) the surface has views displayed on
|
|
|
|
*
|
|
|
|
* \param es The surface to remap to outputs
|
|
|
|
*
|
|
|
|
* Finds the output that is showing the largest amount of one
|
|
|
|
* of the surface's various views. This output becomes the
|
2016-03-30 14:33:33 +03:00
|
|
|
* surface's primary output for vsync and frame callback purposes.
|
2015-12-23 22:01:58 +03:00
|
|
|
*
|
2016-03-30 14:33:33 +03:00
|
|
|
* Also notes all outputs of all of the surface's views
|
2015-12-23 22:01:58 +03:00
|
|
|
* in the output_mask for the surface.
|
|
|
|
*/
|
2012-09-25 22:48:04 +04:00
|
|
|
static void
|
|
|
|
weston_surface_assign_output(struct weston_surface *es)
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_output *new_output;
|
|
|
|
struct weston_view *view;
|
|
|
|
pixman_region32_t region;
|
|
|
|
uint32_t max, area, mask;
|
|
|
|
pixman_box32_t *e;
|
|
|
|
|
|
|
|
new_output = NULL;
|
|
|
|
max = 0;
|
|
|
|
mask = 0;
|
|
|
|
pixman_region32_init(®ion);
|
|
|
|
wl_list_for_each(view, &es->views, surface_link) {
|
|
|
|
if (!view->output)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pixman_region32_intersect(®ion, &view->transform.boundingbox,
|
|
|
|
&view->output->region);
|
|
|
|
|
|
|
|
e = pixman_region32_extents(®ion);
|
|
|
|
area = (e->x2 - e->x1) * (e->y2 - e->y1);
|
|
|
|
|
|
|
|
mask |= view->output_mask;
|
|
|
|
|
|
|
|
if (area >= max) {
|
|
|
|
new_output = view->output;
|
|
|
|
max = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pixman_region32_fini(®ion);
|
|
|
|
|
|
|
|
es->output = new_output;
|
|
|
|
weston_surface_update_output_mask(es, mask);
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:01:58 +03:00
|
|
|
/** Recalculate which output(s) the view is displayed on
|
|
|
|
*
|
|
|
|
* \param ev The view to remap to outputs
|
|
|
|
*
|
|
|
|
* Identifies the set of outputs that the view is visible on,
|
|
|
|
* noting them into the output_mask. The output that the view
|
2016-03-30 14:33:33 +03:00
|
|
|
* is most visible on is set as the view's primary output.
|
2015-12-23 22:01:58 +03:00
|
|
|
*
|
|
|
|
* Also does the same for the view's surface. See
|
|
|
|
* weston_surface_assign_output().
|
|
|
|
*/
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
static void
|
|
|
|
weston_view_assign_output(struct weston_view *ev)
|
|
|
|
{
|
|
|
|
struct weston_compositor *ec = ev->surface->compositor;
|
2012-09-25 22:48:04 +04:00
|
|
|
struct weston_output *output, *new_output;
|
|
|
|
pixman_region32_t region;
|
|
|
|
uint32_t max, area, mask;
|
|
|
|
pixman_box32_t *e;
|
|
|
|
|
|
|
|
new_output = NULL;
|
|
|
|
max = 0;
|
|
|
|
mask = 0;
|
|
|
|
pixman_region32_init(®ion);
|
|
|
|
wl_list_for_each(output, &ec->output_list, link) {
|
2015-07-12 10:52:32 +03:00
|
|
|
if (output->destroying)
|
|
|
|
continue;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_intersect(®ion, &ev->transform.boundingbox,
|
2012-09-25 22:48:04 +04:00
|
|
|
&output->region);
|
|
|
|
|
|
|
|
e = pixman_region32_extents(®ion);
|
|
|
|
area = (e->x2 - e->x1) * (e->y2 - e->y1);
|
|
|
|
|
|
|
|
if (area > 0)
|
2015-12-24 05:38:07 +03:00
|
|
|
mask |= 1u << output->id;
|
2012-09-25 22:48:04 +04:00
|
|
|
|
|
|
|
if (area >= max) {
|
|
|
|
new_output = output;
|
|
|
|
max = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pixman_region32_fini(®ion);
|
|
|
|
|
2018-04-26 12:08:10 +03:00
|
|
|
weston_view_set_output(ev, new_output);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
ev->output_mask = mask;
|
|
|
|
|
|
|
|
weston_surface_assign_output(ev->surface);
|
2012-09-25 22:48:04 +04:00
|
|
|
}
|
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
static void
|
|
|
|
weston_view_to_view_map(struct weston_view *from, struct weston_view *to,
|
|
|
|
int from_x, int from_y, int *to_x, int *to_y)
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
weston_view_to_global_float(from, from_x, from_y, &x, &y);
|
|
|
|
weston_view_from_global_float(to, x, y, &x, &y);
|
|
|
|
|
|
|
|
*to_x = round(x);
|
|
|
|
*to_y = round(y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_view_transfer_scissor(struct weston_view *from, struct weston_view *to)
|
|
|
|
{
|
|
|
|
pixman_box32_t *a;
|
|
|
|
pixman_box32_t b;
|
|
|
|
|
|
|
|
a = pixman_region32_extents(&from->geometry.scissor);
|
|
|
|
|
|
|
|
weston_view_to_view_map(from, to, a->x1, a->y1, &b.x1, &b.y1);
|
|
|
|
weston_view_to_view_map(from, to, a->x2, a->y2, &b.x2, &b.y2);
|
|
|
|
|
|
|
|
pixman_region32_fini(&to->geometry.scissor);
|
|
|
|
pixman_region32_init_with_extents(&to->geometry.scissor, &b);
|
|
|
|
}
|
|
|
|
|
2012-01-25 17:17:40 +04:00
|
|
|
static void
|
2015-02-23 13:27:00 +03:00
|
|
|
view_compute_bbox(struct weston_view *view, const pixman_box32_t *inbox,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_t *bbox)
|
2012-01-25 17:17:40 +04:00
|
|
|
{
|
2012-09-30 04:57:21 +04:00
|
|
|
float min_x = HUGE_VALF, min_y = HUGE_VALF;
|
|
|
|
float max_x = -HUGE_VALF, max_y = -HUGE_VALF;
|
2012-01-25 17:17:40 +04:00
|
|
|
int32_t s[4][2] = {
|
2015-02-23 13:27:00 +03:00
|
|
|
{ inbox->x1, inbox->y1 },
|
|
|
|
{ inbox->x1, inbox->y2 },
|
|
|
|
{ inbox->x2, inbox->y1 },
|
|
|
|
{ inbox->x2, inbox->y2 },
|
2012-01-25 17:17:40 +04:00
|
|
|
};
|
2012-09-30 04:57:21 +04:00
|
|
|
float int_x, int_y;
|
2012-01-25 17:17:40 +04:00
|
|
|
int i;
|
|
|
|
|
2015-02-23 13:27:00 +03:00
|
|
|
if (inbox->x1 == inbox->x2 || inbox->y1 == inbox->y2) {
|
2012-09-04 14:55:44 +04:00
|
|
|
/* avoid rounding empty bbox to 1x1 */
|
|
|
|
pixman_region32_init(bbox);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-25 17:17:40 +04:00
|
|
|
for (i = 0; i < 4; ++i) {
|
2012-09-30 04:57:21 +04:00
|
|
|
float x, y;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_to_global_float(view, s[i][0], s[i][1], &x, &y);
|
2012-01-25 17:17:40 +04:00
|
|
|
if (x < min_x)
|
|
|
|
min_x = x;
|
|
|
|
if (x > max_x)
|
|
|
|
max_x = x;
|
|
|
|
if (y < min_y)
|
|
|
|
min_y = y;
|
|
|
|
if (y > max_y)
|
|
|
|
max_y = y;
|
|
|
|
}
|
|
|
|
|
2012-02-08 17:38:37 +04:00
|
|
|
int_x = floorf(min_x);
|
|
|
|
int_y = floorf(min_y);
|
|
|
|
pixman_region32_init_rect(bbox, int_x, int_y,
|
|
|
|
ceilf(max_x) - int_x, ceilf(max_y) - int_y);
|
2012-01-25 17:17:40 +04:00
|
|
|
}
|
|
|
|
|
2020-06-08 11:22:32 +03:00
|
|
|
static void
|
|
|
|
weston_view_update_transform_scissor(struct weston_view *view,
|
|
|
|
pixman_region32_t *region)
|
|
|
|
{
|
|
|
|
struct weston_view *parent = view->geometry.parent;
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
if (parent->geometry.scissor_enabled) {
|
|
|
|
view->geometry.scissor_enabled = true;
|
|
|
|
weston_view_transfer_scissor(parent, view);
|
|
|
|
} else {
|
|
|
|
view->geometry.scissor_enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view->geometry.scissor_enabled)
|
|
|
|
pixman_region32_intersect(region, region,
|
|
|
|
&view->geometry.scissor);
|
|
|
|
}
|
2012-02-08 17:14:17 +04:00
|
|
|
static void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform_disable(struct weston_view *view)
|
2012-02-08 17:14:17 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.enabled = 0;
|
2012-02-08 17:14:17 +04:00
|
|
|
|
2012-02-13 12:34:04 +04:00
|
|
|
/* round off fractions when not transformed */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->geometry.x = roundf(view->geometry.x);
|
|
|
|
view->geometry.y = roundf(view->geometry.y);
|
2012-02-13 12:34:04 +04:00
|
|
|
|
2013-02-20 02:04:50 +04:00
|
|
|
/* Otherwise identity matrix, but with x and y translation. */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.position.matrix.type = WESTON_MATRIX_TRANSFORM_TRANSLATE;
|
|
|
|
view->transform.position.matrix.d[12] = view->geometry.x;
|
|
|
|
view->transform.position.matrix.d[13] = view->geometry.y;
|
2013-02-20 02:04:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.matrix = view->transform.position.matrix;
|
2013-02-20 02:04:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.inverse = view->transform.position.matrix;
|
|
|
|
view->transform.inverse.d[12] = -view->geometry.x;
|
|
|
|
view->transform.inverse.d[13] = -view->geometry.y;
|
2013-02-20 02:04:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_init_rect(&view->transform.boundingbox,
|
2015-02-16 15:39:11 +03:00
|
|
|
0, 0,
|
2013-12-03 07:01:53 +04:00
|
|
|
view->surface->width,
|
|
|
|
view->surface->height);
|
2020-06-08 11:22:32 +03:00
|
|
|
|
|
|
|
weston_view_update_transform_scissor(view, &view->transform.boundingbox);
|
2015-02-16 15:39:11 +03:00
|
|
|
|
|
|
|
pixman_region32_translate(&view->transform.boundingbox,
|
|
|
|
view->geometry.x, view->geometry.y);
|
2012-02-24 01:11:59 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->alpha == 1.0) {
|
|
|
|
pixman_region32_copy(&view->transform.opaque,
|
|
|
|
&view->surface->opaque);
|
2022-01-13 01:30:26 +03:00
|
|
|
if (view->geometry.scissor_enabled)
|
|
|
|
pixman_region32_intersect(&view->transform.opaque,
|
|
|
|
&view->transform.opaque,
|
|
|
|
&view->geometry.scissor);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_translate(&view->transform.opaque,
|
|
|
|
view->geometry.x,
|
|
|
|
view->geometry.y);
|
2012-02-28 18:19:39 +04:00
|
|
|
}
|
2012-02-08 17:14:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform_enable(struct weston_view *view)
|
2012-01-20 16:24:25 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *parent = view->geometry.parent;
|
|
|
|
struct weston_matrix *matrix = &view->transform.matrix;
|
|
|
|
struct weston_matrix *inverse = &view->transform.inverse;
|
2012-01-20 16:24:25 +04:00
|
|
|
struct weston_transform *tform;
|
2015-02-16 15:39:11 +03:00
|
|
|
pixman_region32_t surfregion;
|
|
|
|
const pixman_box32_t *surfbox;
|
2012-01-20 16:24:25 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.enabled = 1;
|
2012-01-20 16:24:25 +04:00
|
|
|
|
2012-02-08 17:14:17 +04:00
|
|
|
/* Otherwise identity matrix, but with x and y translation. */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.position.matrix.type = WESTON_MATRIX_TRANSFORM_TRANSLATE;
|
|
|
|
view->transform.position.matrix.d[12] = view->geometry.x;
|
|
|
|
view->transform.position.matrix.d[13] = view->geometry.y;
|
2012-01-25 15:37:39 +04:00
|
|
|
|
2012-01-20 16:24:25 +04:00
|
|
|
weston_matrix_init(matrix);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(tform, &view->geometry.transformation_list, link)
|
2012-01-20 16:24:25 +04:00
|
|
|
weston_matrix_multiply(matrix, &tform->matrix);
|
|
|
|
|
2013-03-08 16:56:50 +04:00
|
|
|
if (parent)
|
|
|
|
weston_matrix_multiply(matrix, &parent->transform.matrix);
|
|
|
|
|
2012-01-23 12:02:47 +04:00
|
|
|
if (weston_matrix_invert(inverse, matrix) < 0) {
|
|
|
|
/* Oops, bad total transformation, not invertible */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_log("error: weston_view %p"
|
|
|
|
" transformation not invertible.\n", view);
|
2012-02-08 17:14:17 +04:00
|
|
|
return -1;
|
2012-01-23 12:02:47 +04:00
|
|
|
}
|
2012-01-25 17:17:40 +04:00
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
pixman_region32_init_rect(&surfregion, 0, 0,
|
|
|
|
view->surface->width, view->surface->height);
|
2020-06-08 11:22:32 +03:00
|
|
|
|
|
|
|
weston_view_update_transform_scissor(view, &surfregion);
|
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
surfbox = pixman_region32_extents(&surfregion);
|
|
|
|
|
|
|
|
view_compute_bbox(view, surfbox, &view->transform.boundingbox);
|
|
|
|
pixman_region32_fini(&surfregion);
|
2012-02-24 01:11:59 +04:00
|
|
|
|
2020-08-19 12:31:03 +03:00
|
|
|
if (view->alpha == 1.0 &&
|
|
|
|
matrix->type == WESTON_MATRIX_TRANSFORM_TRANSLATE) {
|
|
|
|
pixman_region32_copy(&view->transform.opaque,
|
|
|
|
&view->surface->opaque);
|
2022-01-13 01:30:26 +03:00
|
|
|
if (view->geometry.scissor_enabled)
|
|
|
|
pixman_region32_intersect(&view->transform.opaque,
|
|
|
|
&view->transform.opaque,
|
|
|
|
&view->geometry.scissor);
|
2020-08-19 12:31:03 +03:00
|
|
|
pixman_region32_translate(&view->transform.opaque,
|
|
|
|
matrix->d[12],
|
|
|
|
matrix->d[13]);
|
|
|
|
}
|
|
|
|
|
2012-02-08 17:14:17 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-09 23:12:57 +04:00
|
|
|
static struct weston_layer *
|
|
|
|
get_view_layer(struct weston_view *view)
|
|
|
|
{
|
|
|
|
if (view->parent_view)
|
|
|
|
return get_view_layer(view->parent_view);
|
|
|
|
return view->layer_link.layer;
|
|
|
|
}
|
|
|
|
|
2012-02-08 17:14:17 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform(struct weston_view *view)
|
2012-02-08 17:14:17 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *parent = view->geometry.parent;
|
2014-07-09 23:12:57 +04:00
|
|
|
struct weston_layer *layer;
|
|
|
|
pixman_region32_t mask;
|
2013-03-08 16:56:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (!view->transform.dirty)
|
2012-02-08 17:14:17 +04:00
|
|
|
return;
|
|
|
|
|
2013-03-08 16:56:50 +04:00
|
|
|
if (parent)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform(parent);
|
2013-03-08 16:56:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.dirty = 0;
|
2012-02-08 17:14:17 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_damage_below(view);
|
2012-02-09 17:32:15 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_fini(&view->transform.boundingbox);
|
|
|
|
pixman_region32_fini(&view->transform.opaque);
|
|
|
|
pixman_region32_init(&view->transform.opaque);
|
2012-02-24 01:11:59 +04:00
|
|
|
|
2012-02-08 17:14:17 +04:00
|
|
|
/* transform.position is always in transformation_list */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->geometry.transformation_list.next ==
|
|
|
|
&view->transform.position.link &&
|
|
|
|
view->geometry.transformation_list.prev ==
|
|
|
|
&view->transform.position.link &&
|
2013-03-08 16:56:50 +04:00
|
|
|
!parent) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform_disable(view);
|
2012-02-08 17:14:17 +04:00
|
|
|
} else {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (weston_view_update_transform_enable(view) < 0)
|
|
|
|
weston_view_update_transform_disable(view);
|
2012-02-08 17:14:17 +04:00
|
|
|
}
|
2012-02-09 17:32:15 +04:00
|
|
|
|
2014-07-09 23:12:57 +04:00
|
|
|
layer = get_view_layer(view);
|
|
|
|
if (layer) {
|
|
|
|
pixman_region32_init_with_extents(&mask, &layer->mask);
|
2015-02-19 12:15:33 +03:00
|
|
|
pixman_region32_intersect(&view->transform.boundingbox,
|
|
|
|
&view->transform.boundingbox, &mask);
|
2015-02-18 17:30:47 +03:00
|
|
|
pixman_region32_intersect(&view->transform.opaque,
|
|
|
|
&view->transform.opaque, &mask);
|
2014-07-09 23:12:57 +04:00
|
|
|
pixman_region32_fini(&mask);
|
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_damage_below(view);
|
2012-02-09 17:32:15 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_assign_output(view);
|
2013-06-12 22:43:21 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_signal_emit(&view->surface->compositor->transform_signal,
|
|
|
|
view->surface);
|
2012-01-20 16:24:25 +04:00
|
|
|
}
|
|
|
|
|
2013-03-08 16:56:49 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_geometry_dirty(struct weston_view *view)
|
2013-03-08 16:56:49 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *child;
|
2013-03-08 16:56:50 +04:00
|
|
|
|
|
|
|
/*
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
* The invariant: if view->geometry.dirty, then all views
|
|
|
|
* in view->geometry.child_list have geometry.dirty too.
|
2013-03-08 16:56:50 +04:00
|
|
|
* Corollary: if not parent->geometry.dirty, then all ancestors
|
|
|
|
* are not dirty.
|
|
|
|
*/
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->transform.dirty)
|
2013-03-08 16:56:50 +04:00
|
|
|
return;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->transform.dirty = 1;
|
2013-03-08 16:56:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(child, &view->geometry.child_list,
|
2013-03-08 16:56:50 +04:00
|
|
|
geometry.parent_link)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_geometry_dirty(child);
|
2013-03-08 16:56:49 +04:00
|
|
|
}
|
|
|
|
|
2012-05-08 20:17:53 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_to_global_fixed(struct weston_view *view,
|
|
|
|
wl_fixed_t vx, wl_fixed_t vy,
|
|
|
|
wl_fixed_t *x, wl_fixed_t *y)
|
2012-05-08 20:17:53 +04:00
|
|
|
{
|
2012-09-30 04:57:21 +04:00
|
|
|
float xf, yf;
|
2012-05-08 20:17:53 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_to_global_float(view,
|
|
|
|
wl_fixed_to_double(vx),
|
|
|
|
wl_fixed_to_double(vy),
|
|
|
|
&xf, &yf);
|
2012-05-08 20:17:53 +04:00
|
|
|
*x = wl_fixed_from_double(xf);
|
|
|
|
*y = wl_fixed_from_double(yf);
|
|
|
|
}
|
|
|
|
|
2012-09-06 05:59:35 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_from_global_float(struct weston_view *view,
|
|
|
|
float x, float y, float *vx, float *vy)
|
2012-01-24 11:59:29 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->transform.enabled) {
|
2012-01-24 11:59:29 +04:00
|
|
|
struct weston_vector v = { { x, y, 0.0f, 1.0f } };
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_matrix_transform(&view->transform.inverse, &v);
|
2012-01-24 11:59:29 +04:00
|
|
|
|
|
|
|
if (fabsf(v.f[3]) < 1e-6) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("warning: numerical instability in "
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
"weston_view_from_global(), divisor = %g\n",
|
2012-01-24 11:59:29 +04:00
|
|
|
v.f[3]);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
*vx = 0;
|
|
|
|
*vy = 0;
|
2012-01-24 11:59:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
*vx = v.f[0] / v.f[3];
|
|
|
|
*vy = v.f[1] / v.f[3];
|
2012-01-24 11:59:29 +04:00
|
|
|
} else {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
*vx = x - view->geometry.x;
|
|
|
|
*vy = y - view->geometry.y;
|
2012-01-24 11:59:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-08 20:17:53 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_from_global_fixed(struct weston_view *view,
|
|
|
|
wl_fixed_t x, wl_fixed_t y,
|
|
|
|
wl_fixed_t *vx, wl_fixed_t *vy)
|
2012-05-08 20:17:53 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
float vxf, vyf;
|
2012-05-08 20:17:53 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_from_global_float(view,
|
|
|
|
wl_fixed_to_double(x),
|
|
|
|
wl_fixed_to_double(y),
|
|
|
|
&vxf, &vyf);
|
|
|
|
*vx = wl_fixed_from_double(vxf);
|
|
|
|
*vy = wl_fixed_from_double(vyf);
|
2012-05-08 20:17:53 +04:00
|
|
|
}
|
|
|
|
|
2012-01-24 16:47:37 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_from_global(struct weston_view *view,
|
|
|
|
int32_t x, int32_t y, int32_t *vx, int32_t *vy)
|
2012-01-24 16:47:37 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
float vxf, vyf;
|
2012-01-24 16:47:37 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_from_global_float(view, x, y, &vxf, &vyf);
|
|
|
|
*vx = floorf(vxf);
|
|
|
|
*vy = floorf(vyf);
|
2012-01-24 16:47:37 +04:00
|
|
|
}
|
|
|
|
|
2015-12-23 22:01:58 +03:00
|
|
|
/**
|
|
|
|
* \param surface The surface to be repainted
|
|
|
|
*
|
|
|
|
* Marks the output(s) that the surface is shown on as needing to be
|
|
|
|
* repainted. See weston_output_schedule_repaint().
|
|
|
|
*/
|
2012-08-04 00:29:12 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_schedule_repaint(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &surface->compositor->output_list, link)
|
2015-12-24 05:38:07 +03:00
|
|
|
if (surface->output_mask & (1u << output->id))
|
2012-08-04 00:29:12 +04:00
|
|
|
weston_output_schedule_repaint(output);
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:01:58 +03:00
|
|
|
/**
|
|
|
|
* \param view The view to be repainted
|
|
|
|
*
|
|
|
|
* Marks the output(s) that the view is shown on as needing to be
|
|
|
|
* repainted. See weston_output_schedule_repaint().
|
|
|
|
*/
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_view_schedule_repaint(struct weston_view *view)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &view->surface->compositor->output_list, link)
|
2015-12-24 05:38:07 +03:00
|
|
|
if (view->output_mask & (1u << output->id))
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_output_schedule_repaint(output);
|
|
|
|
}
|
|
|
|
|
2015-02-19 14:59:55 +03:00
|
|
|
/**
|
|
|
|
* XXX: This function does it the wrong way.
|
|
|
|
* surface->damage is the damage from the client, and causes
|
|
|
|
* surface_flush_damage() to copy pixels. No window management action can
|
|
|
|
* cause damage to the client-provided content, warranting re-upload!
|
|
|
|
*
|
|
|
|
* Instead of surface->damage, this function should record the damage
|
|
|
|
* with all the views for this surface to avoid extraneous texture
|
|
|
|
* uploads.
|
|
|
|
*/
|
2011-04-23 21:04:11 +04:00
|
|
|
WL_EXPORT void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_surface_damage(struct weston_surface *surface)
|
2011-02-13 21:00:51 +03:00
|
|
|
{
|
2012-06-18 23:09:11 +04:00
|
|
|
pixman_region32_union_rect(&surface->damage, &surface->damage,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
0, 0, surface->width,
|
|
|
|
surface->height);
|
2012-01-26 15:12:45 +04:00
|
|
|
|
2012-08-04 00:29:12 +04:00
|
|
|
weston_surface_schedule_repaint(surface);
|
2011-02-13 21:00:51 +03:00
|
|
|
}
|
|
|
|
|
2012-02-13 15:03:59 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_set_position(struct weston_view *view, float x, float y)
|
2012-02-13 15:03:59 +04:00
|
|
|
{
|
2013-12-03 07:01:53 +04:00
|
|
|
if (view->geometry.x == x && view->geometry.y == y)
|
|
|
|
return;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->geometry.x = x;
|
|
|
|
view->geometry.y = y;
|
|
|
|
weston_view_geometry_dirty(view);
|
2012-02-13 15:03:59 +04:00
|
|
|
}
|
|
|
|
|
2013-03-08 16:56:50 +04:00
|
|
|
static void
|
|
|
|
transform_parent_handle_parent_destroy(struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view =
|
|
|
|
container_of(listener, struct weston_view,
|
2013-03-08 16:56:50 +04:00
|
|
|
geometry.parent_destroy_listener);
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_set_transform_parent(view, NULL);
|
2013-03-08 16:56:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_set_transform_parent(struct weston_view *view,
|
2015-02-16 15:39:11 +03:00
|
|
|
struct weston_view *parent)
|
2013-03-08 16:56:50 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (view->geometry.parent) {
|
|
|
|
wl_list_remove(&view->geometry.parent_destroy_listener.link);
|
|
|
|
wl_list_remove(&view->geometry.parent_link);
|
2015-02-16 15:39:11 +03:00
|
|
|
|
|
|
|
if (!parent)
|
|
|
|
view->geometry.scissor_enabled = false;
|
2013-03-08 16:56:50 +04:00
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->geometry.parent = parent;
|
2013-03-08 16:56:50 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view->geometry.parent_destroy_listener.notify =
|
2013-03-08 16:56:50 +04:00
|
|
|
transform_parent_handle_parent_destroy;
|
|
|
|
if (parent) {
|
2013-06-07 07:34:41 +04:00
|
|
|
wl_signal_add(&parent->destroy_signal,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
&view->geometry.parent_destroy_listener);
|
2013-03-08 16:56:50 +04:00
|
|
|
wl_list_insert(&parent->geometry.child_list,
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
&view->geometry.parent_link);
|
2013-03-08 16:56:50 +04:00
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
}
|
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
/** Set a clip mask rectangle on a view
|
|
|
|
*
|
|
|
|
* \param view The view to set the clip mask on.
|
|
|
|
* \param x Top-left corner X coordinate of the clip rectangle.
|
|
|
|
* \param y Top-left corner Y coordinate of the clip rectangle.
|
|
|
|
* \param width Width of the clip rectangle, non-negative.
|
|
|
|
* \param height Height of the clip rectangle, non-negative.
|
|
|
|
*
|
|
|
|
* A shell may set a clip mask rectangle on a view. Everything outside
|
|
|
|
* the rectangle is cut away for input and output purposes: it is
|
|
|
|
* not drawn and cannot be hit by hit-test based input like pointer
|
|
|
|
* motion or touch-downs. Everything inside the rectangle will behave
|
|
|
|
* normally. Clients are unaware of clipping.
|
|
|
|
*
|
2016-04-28 19:59:10 +03:00
|
|
|
* The rectangle is set in surface-local coordinates. Setting a clip
|
2015-02-16 15:39:11 +03:00
|
|
|
* mask rectangle does not affect the view position, the view is positioned
|
|
|
|
* as it would be without a clip. The clip also does not change
|
|
|
|
* weston_surface::width,height.
|
|
|
|
*
|
|
|
|
* The clip mask rectangle is part of transformation inheritance
|
|
|
|
* (weston_view_set_transform_parent()). A clip set in the root of the
|
|
|
|
* transformation inheritance tree will affect all views in the tree.
|
|
|
|
* A clip can be set only on the root view. Attempting to set a clip
|
|
|
|
* on view that has a transformation parent will fail. Assigning a parent
|
|
|
|
* to a view that has a clip set will cause the clip to be forgotten.
|
|
|
|
*
|
|
|
|
* Because the clip mask is an axis-aligned rectangle, it poses restrictions
|
|
|
|
* on the additional transformations in the child views. These transformations
|
|
|
|
* may not rotate the coordinate axes, i.e., only translation and scaling
|
|
|
|
* are allowed. Violating this restriction causes the clipping to malfunction.
|
|
|
|
* Furthermore, using scaling may cause rounding errors in child clipping.
|
|
|
|
*
|
|
|
|
* The clip mask rectangle is not automatically adjusted based on
|
|
|
|
* wl_surface.attach dx and dy arguments.
|
|
|
|
*
|
|
|
|
* A clip mask rectangle can be set only if the compositor capability
|
|
|
|
* WESTON_CAP_VIEW_CLIP_MASK is present.
|
|
|
|
*
|
|
|
|
* This function sets the clip mask rectangle and schedules a repaint for
|
|
|
|
* the view.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_view_set_mask(struct weston_view *view,
|
|
|
|
int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = view->surface->compositor;
|
|
|
|
|
|
|
|
if (!(compositor->capabilities & WESTON_CAP_VIEW_CLIP_MASK)) {
|
|
|
|
weston_log("%s not allowed without capability!\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view->geometry.parent) {
|
|
|
|
weston_log("view %p has a parent, clip forbidden!\n", view);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
weston_log("%s: illegal args %d, %d, %d, %d\n", __func__,
|
|
|
|
x, y, width, height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_fini(&view->geometry.scissor);
|
|
|
|
pixman_region32_init_rect(&view->geometry.scissor, x, y, width, height);
|
|
|
|
view->geometry.scissor_enabled = true;
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
weston_view_schedule_repaint(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove the clip mask from a view
|
|
|
|
*
|
|
|
|
* \param view The view to remove the clip mask from.
|
|
|
|
*
|
|
|
|
* Removed the clip mask rectangle and schedules a repaint.
|
|
|
|
*
|
|
|
|
* \sa weston_view_set_mask
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_view_set_mask_infinite(struct weston_view *view)
|
|
|
|
{
|
|
|
|
view->geometry.scissor_enabled = false;
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
weston_view_schedule_repaint(view);
|
|
|
|
}
|
|
|
|
|
2016-06-30 07:04:33 +03:00
|
|
|
/* Check if view should be displayed
|
|
|
|
*
|
|
|
|
* The indicator is set manually when assigning
|
|
|
|
* a view to a surface.
|
|
|
|
*
|
|
|
|
* This needs reworking. See the thread starting at:
|
|
|
|
*
|
|
|
|
* https://lists.freedesktop.org/archives/wayland-devel/2016-June/029656.html
|
|
|
|
*/
|
2014-10-03 22:13:42 +04:00
|
|
|
WL_EXPORT bool
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_is_mapped(struct weston_view *view)
|
|
|
|
{
|
2016-06-30 07:04:33 +03:00
|
|
|
return view->is_mapped;
|
2013-03-08 16:56:50 +04:00
|
|
|
}
|
|
|
|
|
2018-09-03 21:11:15 +03:00
|
|
|
/* Check if view is opaque in specified region
|
|
|
|
*
|
|
|
|
* \param view The view to check for opacity.
|
|
|
|
* \param region The region to check for opacity, in view coordinates.
|
|
|
|
*
|
|
|
|
* Returns true if the view is opaque in the specified region, because view
|
|
|
|
* alpha is 1.0 and either the opaque region set by the client contains the
|
|
|
|
* specified region, or the buffer pixel format or solid color is opaque.
|
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region)
|
|
|
|
{
|
|
|
|
pixman_region32_t r;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (ev->alpha < 1.0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (ev->surface->is_opaque)
|
|
|
|
return true;
|
|
|
|
|
2020-08-21 13:57:54 +03:00
|
|
|
if (ev->transform.dirty)
|
2018-09-03 21:11:15 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
pixman_region32_init(&r);
|
|
|
|
pixman_region32_subtract(&r, region, &ev->transform.opaque);
|
|
|
|
|
|
|
|
if (!pixman_region32_not_empty(&r))
|
|
|
|
ret = true;
|
|
|
|
|
|
|
|
pixman_region32_fini(&r);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-11 16:41:04 +03:00
|
|
|
/** Check if the view has a valid buffer available
|
|
|
|
*
|
|
|
|
* @param ev The view to check if it has a valid buffer.
|
|
|
|
*
|
|
|
|
* Returns true if the view has a valid buffer or false otherwise.
|
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_view_has_valid_buffer(struct weston_view *ev)
|
|
|
|
{
|
2022-01-14 05:33:03 +03:00
|
|
|
if (!ev->surface->buffer_ref.buffer)
|
|
|
|
return false;
|
|
|
|
if (!ev->surface->buffer_ref.buffer->resource)
|
|
|
|
return false;
|
|
|
|
return true;
|
2019-09-11 16:41:04 +03:00
|
|
|
}
|
|
|
|
|
2019-09-11 16:53:08 +03:00
|
|
|
/** Check if the view matches the entire output
|
|
|
|
*
|
|
|
|
* @param ev The view to check.
|
|
|
|
* @param output The output to check against.
|
|
|
|
*
|
|
|
|
* Returns true if the view does indeed matches the entire output.
|
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_view_matches_output_entirely(struct weston_view *ev,
|
|
|
|
struct weston_output *output)
|
|
|
|
{
|
|
|
|
pixman_box32_t *extents =
|
|
|
|
pixman_region32_extents(&ev->transform.boundingbox);
|
|
|
|
|
|
|
|
if (extents->x1 != output->x ||
|
|
|
|
extents->y1 != output->y ||
|
|
|
|
extents->x2 != output->x + output->width ||
|
|
|
|
extents->y2 != output->y + output->height)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
/** Find paint node for the given view and output
|
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_paint_node *
|
|
|
|
weston_view_find_paint_node(struct weston_view *view,
|
|
|
|
struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct weston_paint_node *pnode;
|
|
|
|
|
|
|
|
wl_list_for_each(pnode, &view->paint_node_list, view_link) {
|
|
|
|
assert(pnode->surface == view->surface);
|
|
|
|
if (pnode->output == output)
|
|
|
|
return pnode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-30 07:04:33 +03:00
|
|
|
/* Check if a surface has a view assigned to it
|
|
|
|
*
|
|
|
|
* The indicator is set manually when mapping
|
|
|
|
* a surface and creating a view for it.
|
|
|
|
*
|
|
|
|
* This needs to go. See the thread starting at:
|
|
|
|
*
|
|
|
|
* https://lists.freedesktop.org/archives/wayland-devel/2016-June/029656.html
|
|
|
|
*
|
|
|
|
*/
|
2014-10-03 22:13:42 +04:00
|
|
|
WL_EXPORT bool
|
2012-03-27 18:36:36 +04:00
|
|
|
weston_surface_is_mapped(struct weston_surface *surface)
|
|
|
|
{
|
2016-06-30 07:04:33 +03:00
|
|
|
return surface->is_mapped;
|
2012-03-27 18:36:36 +04:00
|
|
|
}
|
|
|
|
|
2013-12-03 07:01:53 +04:00
|
|
|
static void
|
2013-12-05 06:32:03 +04:00
|
|
|
surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)
|
2013-12-03 07:01:53 +04:00
|
|
|
{
|
|
|
|
struct weston_view *view;
|
|
|
|
|
|
|
|
if (surface->width == width && surface->height == height)
|
|
|
|
return;
|
|
|
|
|
|
|
|
surface->width = width;
|
|
|
|
surface->height = height;
|
|
|
|
|
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
}
|
|
|
|
|
2013-12-05 06:32:03 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_set_size(struct weston_surface *surface,
|
|
|
|
int32_t width, int32_t height)
|
|
|
|
{
|
|
|
|
assert(!surface->resource);
|
|
|
|
surface_set_size(surface, width, height);
|
|
|
|
}
|
|
|
|
|
2014-03-14 16:38:17 +04:00
|
|
|
static int
|
|
|
|
fixed_round_up_to_int(wl_fixed_t f)
|
|
|
|
{
|
|
|
|
return wl_fixed_to_int(wl_fixed_from_int(1) - 1 + f);
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:19:43 +04:00
|
|
|
static void
|
2016-04-26 15:50:59 +03:00
|
|
|
convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out,
|
|
|
|
int32_t width, int32_t height,
|
|
|
|
uint32_t transform,
|
|
|
|
int32_t scale)
|
2012-11-27 19:03:42 +04:00
|
|
|
{
|
2016-04-26 15:50:59 +03:00
|
|
|
assert(scale > 0);
|
2013-11-26 21:19:46 +04:00
|
|
|
|
2016-04-26 15:50:59 +03:00
|
|
|
switch (transform) {
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
*width_out = width / scale;
|
|
|
|
*height_out = height / scale;
|
|
|
|
break;
|
2012-11-27 19:03:42 +04:00
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
2016-04-26 15:50:59 +03:00
|
|
|
*width_out = height / scale;
|
|
|
|
*height_out = width / scale;
|
2013-11-26 21:19:43 +04:00
|
|
|
break;
|
2012-11-27 19:03:42 +04:00
|
|
|
default:
|
2016-04-26 15:50:59 +03:00
|
|
|
assert(0 && "invalid transform");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
|
|
|
|
|
|
|
if (!surface->buffer_ref.buffer) {
|
|
|
|
surface->width_from_buffer = 0;
|
|
|
|
surface->height_from_buffer = 0;
|
|
|
|
return;
|
2012-11-27 19:03:42 +04:00
|
|
|
}
|
2013-11-26 21:19:43 +04:00
|
|
|
|
2016-04-26 15:50:59 +03:00
|
|
|
convert_size_by_transform_scale(&surface->width_from_buffer,
|
|
|
|
&surface->height_from_buffer,
|
|
|
|
surface->buffer_ref.buffer->width,
|
|
|
|
surface->buffer_ref.buffer->height,
|
|
|
|
vp->buffer.transform,
|
|
|
|
vp->buffer.scale);
|
2014-06-13 20:14:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_update_size(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
|
|
|
int32_t width, height;
|
|
|
|
|
|
|
|
width = surface->width_from_buffer;
|
|
|
|
height = surface->height_from_buffer;
|
2014-03-14 16:38:17 +04:00
|
|
|
|
2014-06-13 20:14:20 +04:00
|
|
|
if (width != 0 && vp->surface.width != -1) {
|
2014-03-14 16:38:17 +04:00
|
|
|
surface_set_size(surface,
|
|
|
|
vp->surface.width, vp->surface.height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-13 20:14:20 +04:00
|
|
|
if (width != 0 && vp->buffer.src_width != wl_fixed_from_int(-1)) {
|
2014-04-04 15:22:13 +04:00
|
|
|
int32_t w = fixed_round_up_to_int(vp->buffer.src_width);
|
|
|
|
int32_t h = fixed_round_up_to_int(vp->buffer.src_height);
|
|
|
|
|
|
|
|
surface_set_size(surface, w ?: 1, h ?: 1);
|
2014-03-14 16:38:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-05 06:32:03 +04:00
|
|
|
surface_set_size(surface, width, height);
|
2012-11-27 19:03:42 +04:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_get_time
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2017-11-16 19:21:01 +03:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_get_time(struct timespec *time)
|
2010-12-07 05:41:10 +03:00
|
|
|
{
|
2017-11-16 19:21:01 +03:00
|
|
|
clock_gettime(CLOCK_REALTIME, time);
|
2010-12-07 05:41:10 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_pick_view
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
WL_EXPORT struct weston_view *
|
|
|
|
weston_compositor_pick_view(struct weston_compositor *compositor,
|
|
|
|
wl_fixed_t x, wl_fixed_t y,
|
|
|
|
wl_fixed_t *vx, wl_fixed_t *vy)
|
2012-02-10 18:26:19 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
2015-02-18 16:08:29 +03:00
|
|
|
wl_fixed_t view_x, view_y;
|
|
|
|
int view_ix, view_iy;
|
|
|
|
int ix = wl_fixed_to_int(x);
|
|
|
|
int iy = wl_fixed_to_int(y);
|
2012-02-10 18:26:19 +04:00
|
|
|
|
2021-05-03 16:09:45 +03:00
|
|
|
/* Can't use paint node list: occlusion by input regions, not opaque. */
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(view, &compositor->view_list, link) {
|
2015-02-18 16:08:29 +03:00
|
|
|
if (!pixman_region32_contains_point(
|
|
|
|
&view->transform.boundingbox, ix, iy, NULL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
weston_view_from_global_fixed(view, x, y, &view_x, &view_y);
|
|
|
|
view_ix = wl_fixed_to_int(view_x);
|
|
|
|
view_iy = wl_fixed_to_int(view_y);
|
|
|
|
|
|
|
|
if (!pixman_region32_contains_point(&view->surface->input,
|
|
|
|
view_ix, view_iy, NULL))
|
|
|
|
continue;
|
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
if (view->geometry.scissor_enabled &&
|
|
|
|
!pixman_region32_contains_point(&view->geometry.scissor,
|
|
|
|
view_ix, view_iy, NULL))
|
|
|
|
continue;
|
|
|
|
|
2015-02-18 16:08:29 +03:00
|
|
|
*vx = view_x;
|
|
|
|
*vy = view_y;
|
|
|
|
return view;
|
2012-02-10 18:26:19 +04:00
|
|
|
}
|
|
|
|
|
2015-05-11 23:40:11 +03:00
|
|
|
*vx = wl_fixed_from_int(-1000000);
|
|
|
|
*vy = wl_fixed_from_int(-1000000);
|
2012-02-10 18:26:19 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-19 00:48:27 +04:00
|
|
|
static void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_compositor_repick(struct weston_compositor *compositor)
|
2011-10-12 06:20:37 +04:00
|
|
|
{
|
2012-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *seat;
|
2011-10-12 06:20:37 +04:00
|
|
|
|
2013-10-22 23:40:54 +04:00
|
|
|
if (!compositor->session_active)
|
2011-11-16 01:39:55 +04:00
|
|
|
return;
|
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link)
|
2013-05-07 05:51:21 +04:00
|
|
|
weston_seat_repick(seat);
|
2011-10-12 06:20:37 +04:00
|
|
|
}
|
|
|
|
|
2012-06-27 05:19:23 +04:00
|
|
|
WL_EXPORT void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_unmap(struct weston_view *view)
|
2012-02-17 21:43:56 +04:00
|
|
|
{
|
2012-05-30 19:31:53 +04:00
|
|
|
struct weston_seat *seat;
|
2012-03-02 02:09:37 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (!weston_view_is_mapped(view))
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_view_damage_below(view);
|
2018-04-26 12:08:10 +03:00
|
|
|
weston_view_set_output(view, NULL);
|
2013-10-23 09:58:31 +04:00
|
|
|
view->plane = NULL;
|
2016-06-30 07:04:28 +03:00
|
|
|
view->is_mapped = false;
|
2014-07-09 23:12:56 +04:00
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_remove(&view->link);
|
|
|
|
wl_list_init(&view->link);
|
|
|
|
view->output_mask = 0;
|
|
|
|
weston_surface_assign_output(view->surface);
|
|
|
|
|
|
|
|
if (weston_surface_is_mapped(view->surface))
|
|
|
|
return;
|
2012-03-02 02:09:37 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(seat, &view->surface->compositor->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_touch *touch = weston_seat_get_touch(seat);
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
weston_seat_get_keyboard(seat);
|
|
|
|
|
|
|
|
if (keyboard && keyboard->focus == view->surface)
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
|
|
|
if (pointer && pointer->focus == view)
|
2015-05-11 23:40:11 +03:00
|
|
|
weston_pointer_clear_focus(pointer);
|
2015-08-01 00:55:32 +03:00
|
|
|
if (touch && touch->focus == view)
|
|
|
|
weston_touch_set_focus(touch, NULL);
|
2012-05-30 19:31:53 +04:00
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
}
|
2012-03-02 02:09:37 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_unmap(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_view *view;
|
|
|
|
|
2016-06-30 07:04:28 +03:00
|
|
|
surface->is_mapped = false;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
|
|
|
weston_view_unmap(view);
|
|
|
|
surface->output = NULL;
|
2012-02-17 21:43:56 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 16:38:13 +04:00
|
|
|
static void
|
|
|
|
weston_surface_reset_pending_buffer(struct weston_surface *surface)
|
|
|
|
{
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_set_buffer(&surface->pending, NULL);
|
2014-03-14 16:38:13 +04:00
|
|
|
surface->pending.sx = 0;
|
|
|
|
surface->pending.sy = 0;
|
|
|
|
surface->pending.newly_attached = 0;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 0;
|
2014-03-14 16:38:13 +04:00
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_view_destroy(struct weston_view *view)
|
|
|
|
{
|
2021-04-30 14:48:52 +03:00
|
|
|
struct weston_paint_node *pnode, *pntmp;
|
|
|
|
|
2021-12-09 15:07:21 +03:00
|
|
|
weston_signal_emit_mutable(&view->destroy_signal, view);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
assert(wl_list_empty(&view->geometry.child_list));
|
|
|
|
|
|
|
|
if (weston_view_is_mapped(view)) {
|
|
|
|
weston_view_unmap(view);
|
2021-04-30 14:48:52 +03:00
|
|
|
weston_compositor_build_view_list(view->surface->compositor,
|
|
|
|
NULL);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
}
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
|
|
|
|
weston_paint_node_destroy(pnode);
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_remove(&view->link);
|
2014-07-09 23:12:56 +04:00
|
|
|
weston_layer_entry_remove(&view->layer_link);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
pixman_region32_fini(&view->clip);
|
2015-02-16 15:39:11 +03:00
|
|
|
pixman_region32_fini(&view->geometry.scissor);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_fini(&view->transform.boundingbox);
|
2015-02-18 17:30:47 +03:00
|
|
|
pixman_region32_fini(&view->transform.opaque);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
weston_view_set_transform_parent(view, NULL);
|
2018-05-22 13:15:58 +03:00
|
|
|
weston_view_set_output(view, NULL);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
wl_list_remove(&view->surface_link);
|
|
|
|
|
|
|
|
free(view);
|
|
|
|
}
|
2013-06-07 07:34:41 +04:00
|
|
|
|
libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.
Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.
Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().
The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well. This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).
If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.
Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.
A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-14 23:42:22 +03:00
|
|
|
WL_EXPORT struct weston_surface *
|
|
|
|
weston_surface_ref(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
assert(surface->ref_count < INT32_MAX &&
|
|
|
|
surface->ref_count > 0);
|
|
|
|
|
|
|
|
surface->ref_count++;
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
2013-06-07 07:34:41 +04:00
|
|
|
WL_EXPORT void
|
2022-02-07 11:59:41 +03:00
|
|
|
weston_surface_unref(struct weston_surface *surface)
|
2008-11-24 01:07:32 +03:00
|
|
|
{
|
2021-07-29 11:16:51 +03:00
|
|
|
struct wl_resource *cb, *next;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *ev, *nv;
|
2016-07-22 12:56:31 +03:00
|
|
|
struct weston_pointer_constraint *constraint, *next_constraint;
|
2021-04-30 14:48:52 +03:00
|
|
|
struct weston_paint_node *pnode, *pntmp;
|
2009-03-11 06:17:00 +03:00
|
|
|
|
2022-02-07 12:05:14 +03:00
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert(surface->ref_count > 0);
|
2013-08-14 01:10:14 +04:00
|
|
|
if (--surface->ref_count > 0)
|
|
|
|
return;
|
|
|
|
|
2015-04-17 14:00:24 +03:00
|
|
|
assert(surface->resource == NULL);
|
|
|
|
|
2020-07-09 17:31:34 +03:00
|
|
|
weston_signal_emit_mutable(&surface->destroy_signal, surface);
|
2013-08-14 01:10:14 +04:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
assert(wl_list_empty(&surface->subsurface_list_pending));
|
|
|
|
assert(wl_list_empty(&surface->subsurface_list));
|
2013-03-08 16:56:50 +04:00
|
|
|
|
2021-01-19 01:36:48 +03:00
|
|
|
if (surface->dmabuf_feedback)
|
|
|
|
weston_dmabuf_feedback_destroy(surface->dmabuf_feedback);
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each_safe(ev, nv, &surface->views, surface_link)
|
|
|
|
weston_view_destroy(ev);
|
2011-10-12 06:20:37 +04:00
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_for_each_safe(pnode, pntmp,
|
|
|
|
&surface->paint_node_list, surface_link) {
|
|
|
|
weston_paint_node_destroy(pnode);
|
|
|
|
}
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_fini(&surface->pending);
|
2012-10-10 13:49:23 +04:00
|
|
|
|
2022-01-15 06:12:53 +03:00
|
|
|
weston_buffer_reference(&surface->buffer_ref, NULL,
|
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
2018-10-19 12:14:11 +03:00
|
|
|
weston_buffer_release_reference(&surface->buffer_release_ref, NULL);
|
2009-09-19 01:05:13 +04:00
|
|
|
|
2012-01-03 12:23:24 +04:00
|
|
|
pixman_region32_fini(&surface->damage);
|
2012-02-24 01:11:59 +04:00
|
|
|
pixman_region32_fini(&surface->opaque);
|
2012-10-10 13:49:28 +04:00
|
|
|
pixman_region32_fini(&surface->input);
|
2012-01-03 12:23:24 +04:00
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_resource_for_each_safe(cb, next, &surface->frame_callback_list)
|
|
|
|
wl_resource_destroy(cb);
|
2012-07-22 19:33:14 +04:00
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
weston_presentation_feedback_discard_list(&surface->feedback_list);
|
|
|
|
|
2016-07-22 12:56:31 +03:00
|
|
|
wl_list_for_each_safe(constraint, next_constraint,
|
|
|
|
&surface->pointer_constraints,
|
|
|
|
link)
|
|
|
|
weston_pointer_constraint_destroy(constraint);
|
|
|
|
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
fd_clear(&surface->acquire_fence_fd);
|
|
|
|
|
2009-03-11 06:17:00 +03:00
|
|
|
free(surface);
|
2008-11-24 01:07:32 +03:00
|
|
|
}
|
|
|
|
|
2013-06-07 07:34:41 +04:00
|
|
|
static void
|
|
|
|
destroy_surface(struct wl_resource *resource)
|
2012-02-28 14:07:54 +04:00
|
|
|
{
|
2013-06-07 07:34:41 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2012-02-28 14:07:54 +04:00
|
|
|
|
2015-04-17 14:00:24 +03:00
|
|
|
assert(surface);
|
|
|
|
|
2013-11-16 01:06:15 +04:00
|
|
|
/* Set the resource to NULL, since we don't want to leave a
|
|
|
|
* dangling pointer if the surface was refcounted and survives
|
2022-02-07 11:59:41 +03:00
|
|
|
* the weston_surface_unref() call. */
|
2013-11-16 01:06:15 +04:00
|
|
|
surface->resource = NULL;
|
2016-04-22 14:14:38 +03:00
|
|
|
|
|
|
|
if (surface->viewport_resource)
|
|
|
|
wl_resource_set_user_data(surface->viewport_resource, NULL);
|
|
|
|
|
2018-10-19 12:14:11 +03:00
|
|
|
if (surface->synchronization_resource) {
|
|
|
|
wl_resource_set_user_data(surface->synchronization_resource,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2022-02-07 11:59:41 +03:00
|
|
|
weston_surface_unref(surface);
|
2012-02-28 14:07:54 +04:00
|
|
|
}
|
|
|
|
|
2013-06-21 05:38:23 +04:00
|
|
|
static void
|
|
|
|
weston_buffer_destroy_handler(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_buffer *buffer =
|
|
|
|
container_of(listener, struct weston_buffer, destroy_listener);
|
|
|
|
|
2022-01-14 09:33:21 +03:00
|
|
|
buffer->resource = NULL;
|
|
|
|
buffer->shm_buffer = NULL;
|
|
|
|
|
2022-01-15 05:12:32 +03:00
|
|
|
if (buffer->busy_count + buffer->passive_count > 0)
|
2022-01-14 09:33:21 +03:00
|
|
|
return;
|
|
|
|
|
2021-12-09 15:07:21 +03:00
|
|
|
weston_signal_emit_mutable(&buffer->destroy_signal, buffer);
|
2013-06-21 05:38:23 +04:00
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
|
2013-12-12 17:14:29 +04:00
|
|
|
WL_EXPORT struct weston_buffer *
|
2022-01-14 04:02:21 +03:00
|
|
|
weston_buffer_from_resource(struct weston_compositor *ec,
|
|
|
|
struct wl_resource *resource)
|
2013-06-21 05:38:23 +04:00
|
|
|
{
|
|
|
|
struct weston_buffer *buffer;
|
2022-01-14 03:52:26 +03:00
|
|
|
struct wl_shm_buffer *shm;
|
|
|
|
struct linux_dmabuf_buffer *dmabuf;
|
2013-06-21 05:38:23 +04:00
|
|
|
struct wl_listener *listener;
|
2014-01-18 01:19:01 +04:00
|
|
|
|
2013-06-21 05:38:23 +04:00
|
|
|
listener = wl_resource_get_destroy_listener(resource,
|
|
|
|
weston_buffer_destroy_handler);
|
|
|
|
|
2013-08-15 23:26:42 +04:00
|
|
|
if (listener)
|
|
|
|
return container_of(listener, struct weston_buffer,
|
|
|
|
destroy_listener);
|
|
|
|
|
|
|
|
buffer = zalloc(sizeof *buffer);
|
|
|
|
if (buffer == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
buffer->resource = resource;
|
|
|
|
wl_signal_init(&buffer->destroy_signal);
|
|
|
|
buffer->destroy_listener.notify = weston_buffer_destroy_handler;
|
|
|
|
wl_resource_add_destroy_listener(resource, &buffer->destroy_listener);
|
2014-01-18 01:19:01 +04:00
|
|
|
|
2022-01-14 03:52:26 +03:00
|
|
|
if ((shm = wl_shm_buffer_get(buffer->resource))) {
|
2022-01-14 04:09:51 +03:00
|
|
|
buffer->type = WESTON_BUFFER_SHM;
|
2022-01-14 03:52:26 +03:00
|
|
|
buffer->shm_buffer = shm;
|
|
|
|
buffer->width = wl_shm_buffer_get_width(shm);
|
|
|
|
buffer->height = wl_shm_buffer_get_height(shm);
|
2022-01-15 20:36:02 +03:00
|
|
|
buffer->buffer_origin = ORIGIN_TOP_LEFT;
|
2022-01-14 04:55:50 +03:00
|
|
|
/* wl_shm might create a buffer with an unknown format, so check
|
|
|
|
* and reject */
|
|
|
|
buffer->pixel_format =
|
|
|
|
pixel_format_get_info_shm(wl_shm_buffer_get_format(shm));
|
|
|
|
buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
|
|
|
|
|
2022-04-28 03:44:19 +03:00
|
|
|
if (!buffer->pixel_format || buffer->pixel_format->hide_from_clients)
|
2022-01-14 04:55:50 +03:00
|
|
|
goto fail;
|
2022-01-14 03:52:26 +03:00
|
|
|
} else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) {
|
2022-01-14 04:09:51 +03:00
|
|
|
buffer->type = WESTON_BUFFER_DMABUF;
|
|
|
|
buffer->dmabuf = dmabuf;
|
2022-01-19 20:59:50 +03:00
|
|
|
buffer->direct_display = dmabuf->direct_display;
|
2022-01-14 03:52:26 +03:00
|
|
|
buffer->width = dmabuf->attributes.width;
|
|
|
|
buffer->height = dmabuf->attributes.height;
|
2022-01-14 04:55:50 +03:00
|
|
|
buffer->pixel_format =
|
|
|
|
pixel_format_get_info(dmabuf->attributes.format);
|
|
|
|
/* dmabuf import should assure we don't create a buffer with an
|
|
|
|
* unknown format */
|
2022-04-28 03:44:19 +03:00
|
|
|
assert(buffer->pixel_format && !buffer->pixel_format->hide_from_clients);
|
2022-01-14 04:55:50 +03:00
|
|
|
buffer->format_modifier = dmabuf->attributes.modifier[0];
|
2022-01-15 20:36:02 +03:00
|
|
|
if (dmabuf->attributes.flags & ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT)
|
|
|
|
buffer->buffer_origin = ORIGIN_BOTTOM_LEFT;
|
|
|
|
else
|
|
|
|
buffer->buffer_origin = ORIGIN_TOP_LEFT;
|
2022-01-14 04:02:21 +03:00
|
|
|
} else {
|
|
|
|
/* Only taken for legacy EGL buffers */
|
|
|
|
if (!ec->renderer->fill_buffer_info ||
|
|
|
|
!ec->renderer->fill_buffer_info(ec, buffer)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-01-14 04:09:51 +03:00
|
|
|
buffer->type = WESTON_BUFFER_RENDERER_OPAQUE;
|
2022-01-14 03:52:26 +03:00
|
|
|
}
|
|
|
|
|
2022-01-14 04:55:50 +03:00
|
|
|
/* Don't accept any formats we can't reason about: the importer should
|
|
|
|
* make sure this never happens */
|
|
|
|
assert(buffer->pixel_format);
|
|
|
|
|
2013-06-21 05:38:23 +04:00
|
|
|
return buffer;
|
2022-01-14 04:02:21 +03:00
|
|
|
|
|
|
|
fail:
|
|
|
|
wl_list_remove(&buffer->destroy_listener.link);
|
|
|
|
free(buffer);
|
|
|
|
return NULL;
|
2013-06-21 05:38:23 +04:00
|
|
|
}
|
|
|
|
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_buffer_reference(struct weston_buffer_reference *ref,
|
2022-01-15 06:12:53 +03:00
|
|
|
struct weston_buffer *buffer,
|
|
|
|
enum weston_buffer_reference_type type)
|
2011-02-21 18:24:53 +03:00
|
|
|
{
|
2022-01-15 05:12:32 +03:00
|
|
|
struct weston_buffer_reference old_ref = *ref;
|
|
|
|
|
2022-01-15 06:12:53 +03:00
|
|
|
assert(buffer != NULL || type == BUFFER_WILL_NOT_BE_ACCESSED);
|
|
|
|
|
2022-01-15 05:12:32 +03:00
|
|
|
if (buffer == ref->buffer && type == ref->type)
|
2022-01-14 09:33:21 +03:00
|
|
|
return;
|
|
|
|
|
2022-01-15 05:12:32 +03:00
|
|
|
/* First ref the incoming buffer, so we keep positive refcount */
|
|
|
|
if (buffer) {
|
|
|
|
if (type == BUFFER_MAY_BE_ACCESSED)
|
|
|
|
buffer->busy_count++;
|
|
|
|
else
|
|
|
|
buffer->passive_count++;
|
2012-12-04 17:58:10 +04:00
|
|
|
}
|
|
|
|
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
ref->buffer = buffer;
|
2022-01-15 05:12:32 +03:00
|
|
|
ref->type = type;
|
2022-01-14 09:33:21 +03:00
|
|
|
|
2022-01-15 05:12:32 +03:00
|
|
|
/* Now drop refs to the old buffer, if any */
|
|
|
|
if (!old_ref.buffer)
|
2022-01-14 09:33:21 +03:00
|
|
|
return;
|
|
|
|
|
2022-01-15 05:12:32 +03:00
|
|
|
ref = NULL; /* will no longer be accessed */
|
|
|
|
|
|
|
|
if (old_ref.type == BUFFER_MAY_BE_ACCESSED) {
|
|
|
|
assert(old_ref.buffer->busy_count > 0);
|
|
|
|
old_ref.buffer->busy_count--;
|
|
|
|
|
|
|
|
/* If the wl_buffer lives, then hold on to the weston_buffer,
|
|
|
|
* but send a release event to the client */
|
|
|
|
if (old_ref.buffer->busy_count == 0 &&
|
|
|
|
old_ref.buffer->resource) {
|
|
|
|
assert(wl_resource_get_client(old_ref.buffer->resource));
|
|
|
|
wl_buffer_send_release(old_ref.buffer->resource);
|
|
|
|
}
|
|
|
|
} else if (old_ref.type == BUFFER_WILL_NOT_BE_ACCESSED) {
|
|
|
|
assert(old_ref.buffer->passive_count > 0);
|
|
|
|
old_ref.buffer->passive_count--;
|
|
|
|
} else {
|
|
|
|
assert(!"unknown buffer ref type");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the wl_buffer has gone and this was the last ref, destroy the
|
|
|
|
* weston_buffer, since we'll never need it again */
|
|
|
|
if (old_ref.buffer->busy_count + old_ref.buffer->passive_count == 0 &&
|
|
|
|
!old_ref.buffer->resource) {
|
|
|
|
weston_signal_emit_mutable(&old_ref.buffer->destroy_signal,
|
|
|
|
old_ref.buffer);
|
|
|
|
free(old_ref.buffer);
|
|
|
|
}
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
}
|
|
|
|
|
2018-10-19 12:14:11 +03:00
|
|
|
static void
|
|
|
|
weston_buffer_release_reference_handle_destroy(struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct weston_buffer_release_reference *ref =
|
|
|
|
container_of(listener, struct weston_buffer_release_reference,
|
|
|
|
destroy_listener);
|
|
|
|
|
|
|
|
assert((struct wl_resource *)data == ref->buffer_release->resource);
|
|
|
|
ref->buffer_release = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_buffer_release_destroy(struct weston_buffer_release *buffer_release)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource = buffer_release->resource;
|
|
|
|
int release_fence_fd = buffer_release->fence_fd;
|
|
|
|
|
|
|
|
if (release_fence_fd >= 0) {
|
|
|
|
zwp_linux_buffer_release_v1_send_fenced_release(
|
|
|
|
resource, release_fence_fd);
|
|
|
|
} else {
|
|
|
|
zwp_linux_buffer_release_v1_send_immediate_release(
|
|
|
|
resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_buffer_release_reference(struct weston_buffer_release_reference *ref,
|
|
|
|
struct weston_buffer_release *buffer_release)
|
|
|
|
{
|
|
|
|
if (buffer_release == ref->buffer_release)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ref->buffer_release) {
|
|
|
|
ref->buffer_release->ref_count--;
|
|
|
|
wl_list_remove(&ref->destroy_listener.link);
|
|
|
|
if (ref->buffer_release->ref_count == 0)
|
|
|
|
weston_buffer_release_destroy(ref->buffer_release);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer_release) {
|
|
|
|
buffer_release->ref_count++;
|
|
|
|
wl_resource_add_destroy_listener(buffer_release->resource,
|
|
|
|
&ref->destroy_listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
ref->buffer_release = buffer_release;
|
|
|
|
ref->destroy_listener.notify =
|
|
|
|
weston_buffer_release_reference_handle_destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_buffer_release_move(struct weston_buffer_release_reference *dest,
|
|
|
|
struct weston_buffer_release_reference *src)
|
|
|
|
{
|
|
|
|
weston_buffer_release_reference(dest, src->buffer_release);
|
|
|
|
weston_buffer_release_reference(src, NULL);
|
|
|
|
}
|
|
|
|
|
2022-01-15 20:47:35 +03:00
|
|
|
WL_EXPORT struct weston_buffer_reference *
|
|
|
|
weston_buffer_create_solid_rgba(struct weston_compositor *compositor,
|
|
|
|
float r, float g, float b, float a)
|
|
|
|
{
|
|
|
|
struct weston_buffer_reference *ret = zalloc(sizeof(*ret));
|
2022-01-17 17:48:19 +03:00
|
|
|
struct weston_buffer *buffer;
|
2022-01-15 20:47:35 +03:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2022-01-17 17:48:19 +03:00
|
|
|
buffer = zalloc(sizeof(*buffer));
|
|
|
|
if (!buffer) {
|
2022-01-15 20:47:35 +03:00
|
|
|
free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-01-17 17:48:19 +03:00
|
|
|
wl_signal_init(&buffer->destroy_signal);
|
|
|
|
buffer->type = WESTON_BUFFER_SOLID;
|
|
|
|
buffer->width = 1;
|
|
|
|
buffer->height = 1;
|
|
|
|
buffer->buffer_origin = ORIGIN_TOP_LEFT;
|
|
|
|
buffer->solid.r = r;
|
|
|
|
buffer->solid.g = g;
|
|
|
|
buffer->solid.b = b;
|
|
|
|
buffer->solid.a = a;
|
2022-01-15 20:47:35 +03:00
|
|
|
|
|
|
|
if (a == 1.0) {
|
2022-01-17 17:48:19 +03:00
|
|
|
buffer->pixel_format =
|
2022-01-15 20:47:35 +03:00
|
|
|
pixel_format_get_info_shm(WL_SHM_FORMAT_XRGB8888);
|
|
|
|
} else {
|
2022-01-17 17:48:19 +03:00
|
|
|
buffer->pixel_format =
|
2022-01-15 20:47:35 +03:00
|
|
|
pixel_format_get_info_shm(WL_SHM_FORMAT_ARGB8888);
|
|
|
|
}
|
2022-01-17 17:48:19 +03:00
|
|
|
buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
|
2022-01-15 20:47:35 +03:00
|
|
|
|
2022-01-17 17:48:19 +03:00
|
|
|
weston_buffer_reference(ret, buffer, BUFFER_MAY_BE_ACCESSED);
|
2022-01-15 20:47:35 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-17 17:48:19 +03:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_attach_solid(struct weston_surface *surface,
|
|
|
|
struct weston_buffer_reference *buffer_ref,
|
|
|
|
int w, int h)
|
|
|
|
{
|
|
|
|
struct weston_buffer *buffer = buffer_ref->buffer;
|
|
|
|
|
|
|
|
assert(buffer);
|
|
|
|
assert(buffer->type == WESTON_BUFFER_SOLID);
|
|
|
|
weston_buffer_reference(&surface->buffer_ref, buffer,
|
|
|
|
BUFFER_MAY_BE_ACCESSED);
|
|
|
|
surface->compositor->renderer->attach(surface, buffer);
|
|
|
|
|
|
|
|
weston_surface_set_size(surface, w, h);
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->opaque);
|
|
|
|
if (buffer->solid.a == 1.0) {
|
|
|
|
surface->is_opaque = true;
|
|
|
|
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
|
|
|
|
} else {
|
2022-01-19 06:11:40 +03:00
|
|
|
surface->is_opaque = false;
|
2022-01-17 17:48:19 +03:00
|
|
|
pixman_region32_init(&surface->opaque);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-15 20:47:35 +03:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref)
|
|
|
|
{
|
|
|
|
assert(buffer_ref);
|
|
|
|
assert(buffer_ref->buffer);
|
|
|
|
assert(buffer_ref->type == BUFFER_MAY_BE_ACCESSED);
|
|
|
|
assert(buffer_ref->buffer->type == WESTON_BUFFER_SOLID);
|
|
|
|
weston_buffer_reference(buffer_ref, NULL, BUFFER_WILL_NOT_BE_ACCESSED);
|
|
|
|
free(buffer_ref);
|
|
|
|
}
|
|
|
|
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
static void
|
2013-06-21 05:38:23 +04:00
|
|
|
weston_surface_attach(struct weston_surface *surface,
|
|
|
|
struct weston_buffer *buffer)
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
{
|
2022-01-15 06:12:53 +03:00
|
|
|
weston_buffer_reference(&surface->buffer_ref, buffer,
|
|
|
|
buffer ? BUFFER_MAY_BE_ACCESSED :
|
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
|
2012-12-04 17:58:10 +04:00
|
|
|
if (!buffer) {
|
2012-10-10 13:49:23 +04:00
|
|
|
if (weston_surface_is_mapped(surface))
|
|
|
|
weston_surface_unmap(surface);
|
2012-03-27 18:36:40 +04:00
|
|
|
}
|
|
|
|
|
2012-10-10 13:49:23 +04:00
|
|
|
surface->compositor->renderer->attach(surface, buffer);
|
2014-03-14 16:38:11 +04:00
|
|
|
|
2014-06-13 20:14:20 +04:00
|
|
|
weston_surface_calculate_size_from_buffer(surface);
|
2014-09-24 06:08:46 +04:00
|
|
|
weston_presentation_feedback_discard_list(&surface->feedback_list);
|
2022-01-19 06:11:40 +03:00
|
|
|
|
|
|
|
if (buffer)
|
|
|
|
surface->is_opaque = pixel_format_is_opaque(buffer->pixel_format);
|
2011-02-21 18:24:53 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_damage_all
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2011-04-23 21:04:11 +04:00
|
|
|
WL_EXPORT void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_compositor_damage_all(struct weston_compositor *compositor)
|
2011-04-22 22:01:18 +04:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output *output;
|
2011-04-22 22:01:18 +04:00
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link)
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_output_damage(output);
|
2011-04-22 22:01:18 +04:00
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2011-04-23 21:04:11 +04:00
|
|
|
WL_EXPORT void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_output_damage(struct weston_output *output)
|
2011-04-22 22:01:18 +04:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor *compositor = output->compositor;
|
2011-11-11 20:48:12 +04:00
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
pixman_region32_union(&compositor->primary_plane.damage,
|
|
|
|
&compositor->primary_plane.damage,
|
|
|
|
&output->region);
|
2012-06-20 08:35:59 +04:00
|
|
|
weston_output_schedule_repaint(output);
|
2011-04-22 22:01:18 +04:00
|
|
|
}
|
|
|
|
|
2012-06-18 23:09:11 +04:00
|
|
|
static void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
surface_flush_damage(struct weston_surface *surface)
|
2012-06-18 23:09:11 +04:00
|
|
|
{
|
2022-01-14 03:03:24 +03:00
|
|
|
struct weston_buffer *buffer = surface->buffer_ref.buffer;
|
|
|
|
|
2022-01-14 04:36:54 +03:00
|
|
|
if (buffer && buffer->type == WESTON_BUFFER_SHM)
|
2022-01-14 03:03:24 +03:00
|
|
|
surface->compositor->renderer->flush_damage(surface, buffer);
|
2012-06-18 23:09:11 +04:00
|
|
|
|
2019-09-05 13:12:18 +03:00
|
|
|
if (pixman_region32_not_empty(&surface->damage))
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(surface->compositor, "core_flush_damage", TLP_SURFACE(surface),
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
TLP_OUTPUT(surface->output), TLP_END);
|
|
|
|
|
2014-06-26 21:37:36 +04:00
|
|
|
pixman_region32_clear(&surface->damage);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
view_accumulate_damage(struct weston_view *view,
|
|
|
|
pixman_region32_t *opaque)
|
|
|
|
{
|
|
|
|
pixman_region32_t damage;
|
|
|
|
|
|
|
|
pixman_region32_init(&damage);
|
|
|
|
if (view->transform.enabled) {
|
2012-06-18 23:09:11 +04:00
|
|
|
pixman_box32_t *extents;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
extents = pixman_region32_extents(&view->surface->damage);
|
2015-02-23 13:27:00 +03:00
|
|
|
view_compute_bbox(view, extents, &damage);
|
2012-06-18 23:09:11 +04:00
|
|
|
} else {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_copy(&damage, &view->surface->damage);
|
|
|
|
pixman_region32_translate(&damage,
|
2015-02-23 15:08:25 +03:00
|
|
|
view->geometry.x, view->geometry.y);
|
2012-06-18 23:09:11 +04:00
|
|
|
}
|
|
|
|
|
2015-02-16 15:39:11 +03:00
|
|
|
pixman_region32_intersect(&damage, &damage,
|
|
|
|
&view->transform.boundingbox);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
pixman_region32_subtract(&damage, &damage, opaque);
|
|
|
|
pixman_region32_union(&view->plane->damage,
|
|
|
|
&view->plane->damage, &damage);
|
|
|
|
pixman_region32_fini(&damage);
|
|
|
|
pixman_region32_copy(&view->clip, opaque);
|
2015-02-18 17:30:47 +03:00
|
|
|
pixman_region32_union(opaque, opaque, &view->transform.opaque);
|
2012-06-18 23:09:11 +04:00
|
|
|
}
|
|
|
|
|
2013-03-05 19:30:27 +04:00
|
|
|
static void
|
2020-08-11 13:42:35 +03:00
|
|
|
output_accumulate_damage(struct weston_output *output)
|
2013-03-05 19:30:27 +04:00
|
|
|
{
|
2020-08-11 13:42:35 +03:00
|
|
|
struct weston_compositor *ec = output->compositor;
|
2013-03-05 19:30:27 +04:00
|
|
|
struct weston_plane *plane;
|
2021-05-03 14:06:55 +03:00
|
|
|
struct weston_paint_node *pnode;
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_t opaque, clip;
|
2013-03-05 19:30:27 +04:00
|
|
|
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_init(&clip);
|
2013-03-05 19:30:27 +04:00
|
|
|
|
|
|
|
wl_list_for_each(plane, &ec->plane_list, link) {
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_copy(&plane->clip, &clip);
|
|
|
|
|
|
|
|
pixman_region32_init(&opaque);
|
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
|
|
|
if (pnode->view->plane != plane)
|
2013-03-05 19:30:29 +04:00
|
|
|
continue;
|
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
view_accumulate_damage(pnode->view, &opaque);
|
2013-03-05 19:30:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_union(&clip, &clip, &opaque);
|
|
|
|
pixman_region32_fini(&opaque);
|
2013-03-05 19:30:27 +04:00
|
|
|
}
|
|
|
|
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_fini(&clip);
|
2013-03-05 19:30:27 +04:00
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
|
|
|
pnode->surface->touched = false;
|
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
2020-08-11 13:42:35 +03:00
|
|
|
/* Ignore views not visible on the current output */
|
2021-05-03 14:06:55 +03:00
|
|
|
/* TODO: turn this into assert once z_order_list is pruned. */
|
|
|
|
if (!(pnode->view->output_mask & (1u << output->id)))
|
2020-08-11 13:42:35 +03:00
|
|
|
continue;
|
2021-05-03 14:06:55 +03:00
|
|
|
if (pnode->surface->touched)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
continue;
|
2021-05-03 14:06:55 +03:00
|
|
|
pnode->surface->touched = true;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
surface_flush_damage(pnode->surface);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
2013-03-05 19:30:27 +04:00
|
|
|
/* Both the renderer and the backend have seen the buffer
|
|
|
|
* by now. If renderer needs the buffer, it has its own
|
|
|
|
* reference set. If the backend wants to keep the buffer
|
|
|
|
* around for migrating the surface into a non-primary plane
|
|
|
|
* later, keep_buffer is true. Otherwise, drop the core
|
|
|
|
* reference now, and allow early buffer release. This enables
|
|
|
|
* clients to use single-buffering.
|
|
|
|
*/
|
2021-05-03 14:06:55 +03:00
|
|
|
if (!pnode->surface->keep_buffer) {
|
2022-01-15 06:12:53 +03:00
|
|
|
weston_buffer_reference(&pnode->surface->buffer_ref,
|
2022-01-15 05:18:32 +03:00
|
|
|
pnode->surface->buffer_ref.buffer,
|
2022-01-15 06:12:53 +03:00
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
2018-10-19 12:14:11 +03:00
|
|
|
weston_buffer_release_reference(
|
2021-05-03 14:06:55 +03:00
|
|
|
&pnode->surface->buffer_release_ref, NULL);
|
2018-10-19 12:14:11 +03:00
|
|
|
}
|
2013-03-05 19:30:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
surface_stash_subsurface_views(struct weston_surface *surface)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(sub, &surface->subsurface_list, parent_link) {
|
|
|
|
if (sub->surface == surface)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wl_list_insert_list(&sub->unused_views, &sub->surface->views);
|
|
|
|
wl_list_init(&sub->surface->views);
|
|
|
|
|
|
|
|
surface_stash_subsurface_views(sub->surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_free_unused_subsurface_views(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
struct weston_view *view, *nv;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
wl_list_for_each(sub, &surface->subsurface_list, parent_link) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
if (sub->surface == surface)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
continue;
|
|
|
|
|
2014-06-13 20:10:26 +04:00
|
|
|
wl_list_for_each_safe(view, nv, &sub->unused_views, surface_link) {
|
|
|
|
weston_view_unmap (view);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_destroy(view);
|
2014-06-13 20:10:26 +04:00
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
surface_free_unused_subsurface_views(sub->surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
static struct weston_paint_node *
|
|
|
|
view_ensure_paint_node(struct weston_view *view, struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct weston_paint_node *pnode;
|
|
|
|
|
|
|
|
if (!output)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pnode = weston_view_find_paint_node(view, output);
|
|
|
|
if (pnode)
|
|
|
|
return pnode;
|
|
|
|
|
|
|
|
return weston_paint_node_create(view->surface, view, output);
|
|
|
|
}
|
|
|
|
|
2021-04-30 17:41:29 +03:00
|
|
|
static void
|
|
|
|
add_to_z_order_list(struct weston_output *output,
|
|
|
|
struct weston_paint_node *pnode)
|
|
|
|
{
|
|
|
|
if (!pnode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_remove(&pnode->z_order_link);
|
|
|
|
wl_list_insert(output->paint_node_z_order_list.prev,
|
|
|
|
&pnode->z_order_link);
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Building weston_output::paint_node_z_order_list ensures all
|
|
|
|
* necessary color transform objects are installed.
|
|
|
|
*/
|
|
|
|
weston_paint_node_ensure_color_transform(pnode);
|
2021-04-30 17:41:29 +03:00
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
static void
|
|
|
|
view_list_add_subsurface_view(struct weston_compositor *compositor,
|
|
|
|
struct weston_subsurface *sub,
|
2021-04-30 14:48:52 +03:00
|
|
|
struct weston_view *parent,
|
|
|
|
struct weston_output *output)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
{
|
|
|
|
struct weston_subsurface *child;
|
|
|
|
struct weston_view *view = NULL, *iv;
|
2021-04-30 17:41:29 +03:00
|
|
|
struct weston_paint_node *pnode;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
compositor: ignore unmapped sub-surfaces for view_list
It looks like that in the great conversion introducing weston_view, one
conditional was forgotten from the code that builds the global flat list
of views. Sub-surfaces are added to the view list specially, as they are
not governed by their presence in a layer's view list, and therefore
need an explicit check for mappedness.
The bug, missing the explicit check, caused sub-surfaces to enter the
global view_list regardless of their state. This lead to the pointer
focus picking code processing them, and as the input region defaults to
infinite, picking these unmapped surfaces. Clients then get confused
about the wl_pointer.enter events with unexpected wl_surface.
To trigger this issue, it is enough to just create one additional
wl_surface and make it a sub-surface of a main surface that is or gets
mapped. Literally, just a wl_subsomcpositor_get_subsurface() call is
enough. At some point later, the unmapped sub-surface will get pointer
focus, depending on view stacking order.
Fix the issue by adding a is_mapped check when building the view_list.
Note, that 95ec0f95aa2df74c2da19e7dda24528fa8f765cc accidentally also
prevents this bug from happening, because it adds a test against the
transform.masked_boundingbox in weston_compositor_pick_view().
Reported-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2014-07-28 13:49:24 +04:00
|
|
|
if (!weston_surface_is_mapped(sub->surface))
|
|
|
|
return;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(iv, &sub->unused_views, surface_link) {
|
|
|
|
if (iv->geometry.parent == parent) {
|
|
|
|
view = iv;
|
|
|
|
break;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
if (view) {
|
|
|
|
/* Put it back in the surface's list of views */
|
|
|
|
wl_list_remove(&view->surface_link);
|
|
|
|
wl_list_insert(&sub->surface->views, &view->surface_link);
|
|
|
|
} else {
|
|
|
|
view = weston_view_create(sub->surface);
|
2013-12-03 07:01:53 +04:00
|
|
|
weston_view_set_position(view,
|
|
|
|
sub->position.x,
|
|
|
|
sub->position.y);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_set_transform_parent(view, parent);
|
|
|
|
}
|
|
|
|
|
2014-07-09 23:12:57 +04:00
|
|
|
view->parent_view = parent;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_update_transform(view);
|
2016-06-30 07:04:28 +03:00
|
|
|
view->is_mapped = true;
|
2021-04-30 17:41:29 +03:00
|
|
|
pnode = view_ensure_paint_node(view, output);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
if (wl_list_empty(&sub->surface->subsurface_list)) {
|
|
|
|
wl_list_insert(compositor->view_list.prev, &view->link);
|
2021-04-30 17:41:29 +03:00
|
|
|
add_to_z_order_list(output, pnode);
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(child, &sub->surface->subsurface_list, parent_link) {
|
2021-04-30 17:41:29 +03:00
|
|
|
if (child->surface == sub->surface) {
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
wl_list_insert(compositor->view_list.prev, &view->link);
|
2021-04-30 17:41:29 +03:00
|
|
|
add_to_z_order_list(output, pnode);
|
|
|
|
} else {
|
2021-04-30 14:48:52 +03:00
|
|
|
view_list_add_subsurface_view(compositor, child, view, output);
|
2021-04-30 17:41:29 +03:00
|
|
|
}
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
}
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
2017-01-27 19:30:29 +03:00
|
|
|
/* This recursively adds the sub-surfaces for a view, relying on the
|
|
|
|
* sub-surface order. Thus, if a client restacks the sub-surfaces, that
|
|
|
|
* change first happens to the sub-surface list, and then automatically
|
|
|
|
* propagates here. See weston_surface_damage_subsurfaces() for how the
|
|
|
|
* sub-surfaces receive damage when the client changes the state.
|
|
|
|
*/
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
view_list_add(struct weston_compositor *compositor,
|
2021-04-30 14:48:52 +03:00
|
|
|
struct weston_view *view,
|
|
|
|
struct weston_output *output)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
{
|
2021-04-30 17:41:29 +03:00
|
|
|
struct weston_paint_node *pnode;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_subsurface *sub;
|
|
|
|
|
|
|
|
weston_view_update_transform(view);
|
2021-04-30 17:41:29 +03:00
|
|
|
pnode = view_ensure_paint_node(view, output);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
if (wl_list_empty(&view->surface->subsurface_list)) {
|
|
|
|
wl_list_insert(compositor->view_list.prev, &view->link);
|
2021-04-30 17:41:29 +03:00
|
|
|
add_to_z_order_list(output, pnode);
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(sub, &view->surface->subsurface_list, parent_link) {
|
2021-04-30 17:41:29 +03:00
|
|
|
if (sub->surface == view->surface) {
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
wl_list_insert(compositor->view_list.prev, &view->link);
|
2021-04-30 17:41:29 +03:00
|
|
|
add_to_z_order_list(output, pnode);
|
|
|
|
} else {
|
2021-04-30 14:48:52 +03:00
|
|
|
view_list_add_subsurface_view(compositor, sub, view, output);
|
2021-04-30 17:41:29 +03:00
|
|
|
}
|
compositor: fix sub-surface view stacking order
If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.
This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the
geometry information from weston_surface out into weston_view".
Fix the issues:
In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.
In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.
Reported-by: Julien Isorce <julien.isorce@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2013-11-19 16:03:35 +04:00
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-04-30 14:48:52 +03:00
|
|
|
weston_compositor_build_view_list(struct weston_compositor *compositor,
|
|
|
|
struct weston_output *output)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
{
|
2019-09-17 21:14:56 +03:00
|
|
|
struct weston_view *view, *tmp;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
struct weston_layer *layer;
|
|
|
|
|
2021-04-30 17:41:29 +03:00
|
|
|
if (output) {
|
|
|
|
wl_list_remove(&output->paint_node_z_order_list);
|
|
|
|
wl_list_init(&output->paint_node_z_order_list);
|
|
|
|
}
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(layer, &compositor->layer_list, link)
|
2014-07-09 23:12:56 +04:00
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
surface_stash_subsurface_views(view->surface);
|
|
|
|
|
2019-09-17 21:14:56 +03:00
|
|
|
wl_list_for_each_safe(view, tmp, &compositor->view_list, link)
|
|
|
|
wl_list_init(&view->link);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_init(&compositor->view_list);
|
2019-09-17 21:14:56 +03:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
wl_list_for_each(layer, &compositor->layer_list, link) {
|
2014-07-09 23:12:56 +04:00
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
2021-04-30 14:48:52 +03:00
|
|
|
view_list_add(compositor, view, output);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
|
|
|
wl_list_for_each(layer, &compositor->layer_list, link)
|
2014-07-09 23:12:56 +04:00
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link)
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
surface_free_unused_subsurface_views(view->surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
2014-12-17 17:20:41 +03:00
|
|
|
static void
|
|
|
|
weston_output_take_feedback_list(struct weston_output *output,
|
|
|
|
struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_view *view;
|
|
|
|
struct weston_presentation_feedback *feedback;
|
|
|
|
uint32_t flags = 0xffffffff;
|
|
|
|
|
|
|
|
if (wl_list_empty(&surface->feedback_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* All views must have the flag for the flag to survive. */
|
|
|
|
wl_list_for_each(view, &surface->views, surface_link) {
|
|
|
|
/* ignore views that are not on this output at all */
|
|
|
|
if (view->output_mask & (1u << output->id))
|
|
|
|
flags &= view->psf_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(feedback, &surface->feedback_list, link)
|
|
|
|
feedback->psf_flags = flags;
|
|
|
|
|
|
|
|
wl_list_insert_list(&output->feedback_list, &surface->feedback_list);
|
|
|
|
wl_list_init(&surface->feedback_list);
|
|
|
|
}
|
|
|
|
|
2013-10-22 19:11:26 +04:00
|
|
|
static int
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
weston_output_repaint(struct weston_output *output)
|
2008-10-12 05:21:39 +04:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor *ec = output->compositor;
|
2021-05-03 14:06:55 +03:00
|
|
|
struct weston_paint_node *pnode;
|
2012-01-26 17:40:37 +04:00
|
|
|
struct weston_animation *animation, *next;
|
2021-07-29 11:16:51 +03:00
|
|
|
struct wl_resource *cb, *cnext;
|
2012-06-13 02:01:21 +04:00
|
|
|
struct wl_list frame_callback_list;
|
2013-03-05 19:30:27 +04:00
|
|
|
pixman_region32_t output_damage;
|
2013-10-22 19:11:26 +04:00
|
|
|
int r;
|
2017-11-16 19:20:53 +03:00
|
|
|
uint32_t frame_time_msec;
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
enum weston_hdcp_protection highest_requested = WESTON_HDCP_DISABLE;
|
2008-11-29 01:06:06 +03:00
|
|
|
|
2013-12-14 00:10:55 +04:00
|
|
|
if (output->destroying)
|
|
|
|
return 0;
|
|
|
|
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(ec, "core_repaint_begin", TLP_OUTPUT(output), TLP_END);
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
|
2012-02-29 21:42:35 +04:00
|
|
|
/* Rebuild the surface list and update surface transforms up front. */
|
2021-04-30 14:48:52 +03:00
|
|
|
weston_compositor_build_view_list(ec, output);
|
2012-01-27 16:38:33 +04:00
|
|
|
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
/* Find the highest protection desired for an output */
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
|
|
|
/* TODO: turn this into assert once z_order_list is pruned. */
|
|
|
|
if ((pnode->surface->output_mask & (1u << output->id)) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The desired_protection of the output should be the
|
|
|
|
* maximum of the desired_protection of the surfaces,
|
|
|
|
* that are displayed on that output, to avoid
|
|
|
|
* reducing the protection for existing surfaces.
|
|
|
|
*/
|
|
|
|
if (pnode->surface->desired_protection > highest_requested)
|
|
|
|
highest_requested = pnode->surface->desired_protection;
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
output->desired_protection = highest_requested;
|
|
|
|
|
2014-12-17 17:20:41 +03:00
|
|
|
if (output->assign_planes && !output->disable_planes) {
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
output->assign_planes(output);
|
2014-12-17 17:20:41 +03:00
|
|
|
} else {
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
|
|
|
weston_view_move_to_plane(pnode->view, &ec->primary_plane);
|
|
|
|
pnode->view->psf_flags = 0;
|
2014-12-17 17:20:41 +03:00
|
|
|
}
|
|
|
|
}
|
2012-08-03 23:45:23 +04:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
wl_list_init(&frame_callback_list);
|
2021-05-03 14:06:55 +03:00
|
|
|
wl_list_for_each(pnode, &output->paint_node_z_order_list,
|
|
|
|
z_order_link) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
/* Note: This operation is safe to do multiple times on the
|
|
|
|
* same surface.
|
|
|
|
*/
|
2021-05-03 14:06:55 +03:00
|
|
|
if (pnode->surface->output == output) {
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
wl_list_insert_list(&frame_callback_list,
|
2021-05-03 14:06:55 +03:00
|
|
|
&pnode->surface->frame_callback_list);
|
|
|
|
wl_list_init(&pnode->surface->frame_callback_list);
|
2014-09-24 06:08:46 +04:00
|
|
|
|
2021-05-03 14:06:55 +03:00
|
|
|
weston_output_take_feedback_list(output, pnode->surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 13:42:35 +03:00
|
|
|
output_accumulate_damage(output);
|
compositor: Clear only the the damage that was actually repainted
Instead of clearing the whole output region after a repaint, clear
only the regions that were actually painted. This way, the damage
added when a surface moves from the primary plane to another one is
kept while this region is obscured by the opaque region. This allows
the contents below an overlaid surface to be culled, but to make this
work properly, it is also necessary to change the way previous damage
is drawn.
Consider the following scenario: a surface is moved to an overlay plane
leaving some damage in the primary plane. On the following frame, the
surface on the overlay moves, revealing part of the damaged region on
the primary plane. On the frame after that, the overlaid surface moves
back to its previous position obscuring the region of the primary plane
repainted before. At this point, the repainted region was added to the
output's previous damage so that it is draw to both buffers. But since
this region is now obscured, the redrawing is skipped. If the overlaid
surface moves again revealing this region, one of the buffers actually
contains the wrong content.
To fix this problem, this patch ensures that any previous damage that
would be lost is actually preserved by folding it back into the
primary plane damage just before repainting.
2012-08-15 22:02:05 +04:00
|
|
|
|
2012-02-29 07:31:58 +04:00
|
|
|
pixman_region32_init(&output_damage);
|
|
|
|
pixman_region32_intersect(&output_damage,
|
compositor: Clear only the the damage that was actually repainted
Instead of clearing the whole output region after a repaint, clear
only the regions that were actually painted. This way, the damage
added when a surface moves from the primary plane to another one is
kept while this region is obscured by the opaque region. This allows
the contents below an overlaid surface to be culled, but to make this
work properly, it is also necessary to change the way previous damage
is drawn.
Consider the following scenario: a surface is moved to an overlay plane
leaving some damage in the primary plane. On the following frame, the
surface on the overlay moves, revealing part of the damaged region on
the primary plane. On the frame after that, the overlaid surface moves
back to its previous position obscuring the region of the primary plane
repainted before. At this point, the repainted region was added to the
output's previous damage so that it is draw to both buffers. But since
this region is now obscured, the redrawing is skipped. If the overlaid
surface moves again revealing this region, one of the buffers actually
contains the wrong content.
To fix this problem, this patch ensures that any previous damage that
would be lost is actually preserved by folding it back into the
primary plane damage just before repainting.
2012-08-15 22:02:05 +04:00
|
|
|
&ec->primary_plane.damage, &output->region);
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_subtract(&output_damage,
|
|
|
|
&output_damage, &ec->primary_plane.clip);
|
2011-06-24 05:11:19 +04:00
|
|
|
|
2012-02-23 01:21:41 +04:00
|
|
|
if (output->dirty)
|
|
|
|
weston_output_update_matrix(output);
|
|
|
|
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
r = output->repaint(output, &output_damage);
|
2008-10-12 05:21:39 +04:00
|
|
|
|
2012-02-29 07:31:58 +04:00
|
|
|
pixman_region32_fini(&output_damage);
|
2009-01-01 00:18:42 +03:00
|
|
|
|
2017-03-01 14:34:06 +03:00
|
|
|
output->repaint_needed = false;
|
2017-03-03 19:59:42 +03:00
|
|
|
if (r == 0)
|
|
|
|
output->repaint_status = REPAINT_AWAITING_COMPLETION;
|
2011-03-14 14:07:26 +03:00
|
|
|
|
2012-03-12 00:35:16 +04:00
|
|
|
weston_compositor_repick(ec);
|
|
|
|
|
2017-11-16 19:20:53 +03:00
|
|
|
frame_time_msec = timespec_to_msec(&output->frame_time);
|
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_resource_for_each_safe(cb, cnext, &frame_callback_list) {
|
|
|
|
wl_callback_send_done(cb, frame_time_msec);
|
|
|
|
wl_resource_destroy(cb);
|
2011-03-14 14:07:26 +03:00
|
|
|
}
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2012-06-09 05:40:54 +04:00
|
|
|
wl_list_for_each_safe(animation, next, &output->animation_list, link) {
|
|
|
|
animation->frame_counter++;
|
2017-11-16 19:20:53 +03:00
|
|
|
animation->frame(animation, output, &output->frame_time);
|
2012-06-09 05:40:54 +04:00
|
|
|
}
|
2013-10-22 19:11:26 +04:00
|
|
|
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(ec, "core_repaint_posted", TLP_OUTPUT(output), TLP_END);
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
|
2013-10-22 19:11:26 +04:00
|
|
|
return r;
|
2011-06-21 23:02:12 +04:00
|
|
|
}
|
2011-04-22 20:27:57 +04:00
|
|
|
|
2014-05-21 14:51:49 +04:00
|
|
|
static void
|
|
|
|
weston_output_schedule_repaint_reset(struct weston_output *output)
|
|
|
|
{
|
2017-03-03 19:59:42 +03:00
|
|
|
output->repaint_status = REPAINT_NOT_SCHEDULED;
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(output->compositor, "core_repaint_exit_loop",
|
|
|
|
TLP_OUTPUT(output), TLP_END);
|
2014-05-21 14:51:49 +04:00
|
|
|
}
|
|
|
|
|
2017-03-01 14:34:10 +03:00
|
|
|
static int
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
weston_output_maybe_repaint(struct weston_output *output, struct timespec *now)
|
2014-05-21 17:17:27 +04:00
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = output->compositor;
|
2017-03-01 14:34:10 +03:00
|
|
|
int ret = 0;
|
2017-03-01 14:34:08 +03:00
|
|
|
int64_t msec_to_repaint;
|
2014-05-21 17:17:27 +04:00
|
|
|
|
2017-03-01 14:34:08 +03:00
|
|
|
/* We're not ready yet; come back to make a decision later. */
|
|
|
|
if (output->repaint_status != REPAINT_SCHEDULED)
|
2017-03-01 14:34:10 +03:00
|
|
|
return ret;
|
2017-03-01 14:34:08 +03:00
|
|
|
|
|
|
|
msec_to_repaint = timespec_sub_to_msec(&output->next_repaint, now);
|
|
|
|
if (msec_to_repaint > 1)
|
2017-03-01 14:34:10 +03:00
|
|
|
return ret;
|
2017-03-03 19:59:42 +03:00
|
|
|
|
2017-01-16 18:38:54 +03:00
|
|
|
/* If we're sleeping, drop the repaint machinery entirely; we will
|
|
|
|
* explicitly repaint all outputs when we come back. */
|
|
|
|
if (compositor->state == WESTON_COMPOSITOR_SLEEPING ||
|
|
|
|
compositor->state == WESTON_COMPOSITOR_OFFSCREEN)
|
|
|
|
goto err;
|
2014-05-21 17:17:27 +04:00
|
|
|
|
2017-01-16 18:38:54 +03:00
|
|
|
/* We don't actually need to repaint this output; drop it from
|
|
|
|
* repaint until something causes damage. */
|
|
|
|
if (!output->repaint_needed)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/* If repaint fails, we aren't going to get weston_output_finish_frame
|
|
|
|
* to trigger a new repaint, so drop it from repaint and hope
|
2017-03-01 14:34:08 +03:00
|
|
|
* something schedules a successful repaint later. As repainting may
|
|
|
|
* take some time, re-read our clock as a courtesy to the next
|
|
|
|
* output. */
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
ret = weston_output_repaint(output);
|
2017-03-01 14:34:08 +03:00
|
|
|
weston_compositor_read_presentation_clock(compositor, now);
|
2017-01-16 18:38:54 +03:00
|
|
|
if (ret != 0)
|
|
|
|
goto err;
|
2014-05-21 17:17:27 +04:00
|
|
|
|
2018-06-05 04:37:06 +03:00
|
|
|
output->repainted = true;
|
2017-03-01 14:34:10 +03:00
|
|
|
return ret;
|
2017-01-16 18:38:54 +03:00
|
|
|
|
|
|
|
err:
|
|
|
|
weston_output_schedule_repaint_reset(output);
|
2017-03-01 14:34:10 +03:00
|
|
|
return ret;
|
2017-03-01 14:34:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
output_repaint_timer_arm(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
bool any_should_repaint = false;
|
|
|
|
struct timespec now;
|
2017-03-18 15:01:15 +03:00
|
|
|
int64_t msec_to_next = INT64_MAX;
|
2017-03-01 14:34:08 +03:00
|
|
|
|
|
|
|
weston_compositor_read_presentation_clock(compositor, &now);
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
int64_t msec_to_this;
|
|
|
|
|
|
|
|
if (output->repaint_status != REPAINT_SCHEDULED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
msec_to_this = timespec_sub_to_msec(&output->next_repaint,
|
|
|
|
&now);
|
|
|
|
if (!any_should_repaint || msec_to_this < msec_to_next)
|
|
|
|
msec_to_next = msec_to_this;
|
|
|
|
|
|
|
|
any_should_repaint = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!any_should_repaint)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Even if we should repaint immediately, add the minimum 1 ms delay.
|
|
|
|
* This is a workaround to allow coalescing multiple output repaints
|
|
|
|
* particularly from weston_output_finish_frame()
|
|
|
|
* into the same call, which would not happen if we called
|
|
|
|
* output_repaint_timer_handler() directly.
|
|
|
|
*/
|
|
|
|
if (msec_to_next < 1)
|
|
|
|
msec_to_next = 1;
|
|
|
|
|
|
|
|
wl_event_source_timer_update(compositor->repaint_timer, msec_to_next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
output_repaint_timer_handler(void *data)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
struct weston_output *output;
|
|
|
|
struct timespec now;
|
2018-03-20 17:29:40 +03:00
|
|
|
int ret = 0;
|
2017-03-01 14:34:08 +03:00
|
|
|
|
|
|
|
weston_compositor_read_presentation_clock(compositor, &now);
|
2021-02-10 13:33:03 +03:00
|
|
|
compositor->last_repaint_start = now;
|
2017-03-01 14:34:10 +03:00
|
|
|
|
|
|
|
if (compositor->backend->repaint_begin)
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
compositor->backend->repaint_begin(compositor);
|
2017-03-01 14:34:10 +03:00
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
ret = weston_output_maybe_repaint(output, &now);
|
2017-03-01 14:34:10 +03:00
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2018-06-05 04:37:05 +03:00
|
|
|
if (compositor->backend->repaint_flush)
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
ret = compositor->backend->repaint_flush(compositor);
|
2017-03-01 14:34:10 +03:00
|
|
|
} else {
|
2019-06-30 16:51:10 +03:00
|
|
|
if (compositor->backend->repaint_cancel)
|
compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2021-11-03 13:14:11 +03:00
|
|
|
compositor->backend->repaint_cancel(compositor);
|
2019-06-30 16:51:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != 0) {
|
2018-06-05 04:37:06 +03:00
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
if (output->repainted)
|
|
|
|
weston_output_schedule_repaint_reset(output);
|
|
|
|
}
|
2017-03-01 14:34:10 +03:00
|
|
|
}
|
2017-03-01 14:34:08 +03:00
|
|
|
|
2018-07-10 05:47:15 +03:00
|
|
|
wl_list_for_each(output, &compositor->output_list, link)
|
|
|
|
output->repainted = false;
|
|
|
|
|
2017-03-01 14:34:08 +03:00
|
|
|
output_repaint_timer_arm(compositor);
|
|
|
|
|
2017-01-16 18:38:54 +03:00
|
|
|
return 0;
|
2014-05-21 17:17:27 +04:00
|
|
|
}
|
|
|
|
|
2020-05-28 11:34:04 +03:00
|
|
|
/** Convert a presentation timestamp to another clock domain
|
|
|
|
*
|
|
|
|
* \param compositor The compositor defines the presentation clock domain.
|
|
|
|
* \param presentation_stamp The timestamp in presentation clock domain.
|
|
|
|
* \param presentation_now Current time in presentation clock domain.
|
|
|
|
* \param target_clock Defines the target clock domain.
|
|
|
|
*
|
|
|
|
* This approximation relies on presentation_stamp to be close to current time.
|
|
|
|
* The further it is from current time and the bigger the speed difference
|
|
|
|
* between the two clock domains, the bigger the conversion error.
|
|
|
|
*
|
|
|
|
* Conversion error due to system load is biased and unbounded.
|
|
|
|
*/
|
|
|
|
static struct timespec
|
|
|
|
convert_presentation_time_now(struct weston_compositor *compositor,
|
|
|
|
const struct timespec *presentation_stamp,
|
|
|
|
const struct timespec *presentation_now,
|
|
|
|
clockid_t target_clock)
|
|
|
|
{
|
|
|
|
struct timespec target_now = {};
|
|
|
|
struct timespec target_stamp;
|
|
|
|
int64_t delta_ns;
|
|
|
|
|
|
|
|
if (compositor->presentation_clock == target_clock)
|
|
|
|
return *presentation_stamp;
|
|
|
|
|
|
|
|
clock_gettime(target_clock, &target_now);
|
|
|
|
delta_ns = timespec_sub_to_nsec(presentation_stamp, presentation_now);
|
|
|
|
timespec_add_nsec(&target_stamp, &target_now, delta_ns);
|
|
|
|
|
|
|
|
return target_stamp;
|
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2011-06-21 23:02:12 +04:00
|
|
|
WL_EXPORT void
|
2014-09-24 06:08:45 +04:00
|
|
|
weston_output_finish_frame(struct weston_output *output,
|
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
|
|
|
const struct timespec *stamp,
|
|
|
|
uint32_t presented_flags)
|
2011-06-21 23:02:12 +04:00
|
|
|
{
|
2012-03-06 04:50:08 +04:00
|
|
|
struct weston_compositor *compositor = output->compositor;
|
2014-05-21 17:17:27 +04:00
|
|
|
int32_t refresh_nsec;
|
|
|
|
struct timespec now;
|
2020-05-28 11:34:04 +03:00
|
|
|
struct timespec vblank_monotonic;
|
2017-03-01 14:34:08 +03:00
|
|
|
int64_t msec_rel;
|
2014-09-24 06:08:46 +04:00
|
|
|
|
2017-03-03 19:59:42 +03:00
|
|
|
assert(output->repaint_status == REPAINT_AWAITING_COMPLETION);
|
2021-05-10 11:33:23 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If timestamp of latest vblank is given, it must always go forwards.
|
|
|
|
* If not given, INVALID flag must be set.
|
|
|
|
*/
|
|
|
|
if (stamp)
|
|
|
|
assert(timespec_sub_to_nsec(stamp, &output->frame_time) >= 0);
|
|
|
|
else
|
|
|
|
assert(presented_flags & WP_PRESENTATION_FEEDBACK_INVALID);
|
2017-03-01 14:34:05 +03:00
|
|
|
|
2017-03-01 14:34:08 +03:00
|
|
|
weston_compositor_read_presentation_clock(compositor, &now);
|
|
|
|
|
2017-03-01 14:34:05 +03:00
|
|
|
/* If we haven't been supplied any timestamp at all, we don't have a
|
|
|
|
* timebase to work against, so any delay just wastes time. Push a
|
|
|
|
* repaint as soon as possible so we can get on with it. */
|
2017-03-01 14:34:08 +03:00
|
|
|
if (!stamp) {
|
|
|
|
output->next_repaint = now;
|
2017-03-01 14:34:05 +03:00
|
|
|
goto out;
|
2017-03-01 14:34:08 +03:00
|
|
|
}
|
2017-03-01 14:34:05 +03:00
|
|
|
|
2020-05-28 11:34:04 +03:00
|
|
|
vblank_monotonic = convert_presentation_time_now(compositor,
|
|
|
|
stamp, &now,
|
|
|
|
CLOCK_MONOTONIC);
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(compositor, "core_repaint_finished", TLP_OUTPUT(output),
|
2020-05-28 11:34:04 +03:00
|
|
|
TLP_VBLANK(&vblank_monotonic), TLP_END);
|
2018-03-06 19:56:23 +03:00
|
|
|
|
2015-07-03 15:08:53 +03:00
|
|
|
refresh_nsec = millihz_to_nsec(output->current_mode->refresh);
|
2014-09-24 06:08:46 +04:00
|
|
|
weston_presentation_feedback_present_list(&output->feedback_list,
|
|
|
|
output, refresh_nsec, stamp,
|
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
|
|
|
output->msc,
|
|
|
|
presented_flags);
|
2012-03-06 04:50:08 +04:00
|
|
|
|
2017-11-16 19:20:53 +03:00
|
|
|
output->frame_time = *stamp;
|
2012-03-06 04:50:08 +04:00
|
|
|
|
2017-03-01 14:34:08 +03:00
|
|
|
timespec_add_nsec(&output->next_repaint, stamp, refresh_nsec);
|
|
|
|
timespec_add_msec(&output->next_repaint, &output->next_repaint,
|
|
|
|
-compositor->repaint_msec);
|
|
|
|
msec_rel = timespec_sub_to_msec(&output->next_repaint, &now);
|
2017-03-01 14:34:04 +03:00
|
|
|
|
|
|
|
if (msec_rel < -1000 || msec_rel > 1000) {
|
2015-03-19 13:27:29 +03:00
|
|
|
static bool warned;
|
|
|
|
|
|
|
|
if (!warned)
|
|
|
|
weston_log("Warning: computed repaint delay is "
|
2017-03-01 14:34:08 +03:00
|
|
|
"insane: %lld msec\n", (long long) msec_rel);
|
2015-03-19 13:27:29 +03:00
|
|
|
warned = true;
|
|
|
|
|
2017-03-01 14:34:08 +03:00
|
|
|
output->next_repaint = now;
|
2015-03-19 13:27:29 +03:00
|
|
|
}
|
|
|
|
|
2015-06-21 22:25:15 +03:00
|
|
|
/* Called from restart_repaint_loop and restart happens already after
|
|
|
|
* the deadline given by repaint_msec? In that case we delay until
|
|
|
|
* the deadline of the next frame, to give clients a more predictable
|
|
|
|
* timing of the repaint cycle to lock on. */
|
2017-03-01 00:53:51 +03:00
|
|
|
if (presented_flags == WP_PRESENTATION_FEEDBACK_INVALID &&
|
|
|
|
msec_rel < 0) {
|
|
|
|
while (timespec_sub_to_nsec(&output->next_repaint, &now) < 0) {
|
|
|
|
timespec_add_nsec(&output->next_repaint,
|
|
|
|
&output->next_repaint,
|
|
|
|
refresh_nsec);
|
|
|
|
}
|
|
|
|
}
|
2015-06-21 22:25:15 +03:00
|
|
|
|
2017-03-01 14:34:05 +03:00
|
|
|
out:
|
2017-03-03 19:59:42 +03:00
|
|
|
output->repaint_status = REPAINT_SCHEDULED;
|
2017-03-01 14:34:08 +03:00
|
|
|
output_repaint_timer_arm(compositor);
|
2012-03-06 04:50:08 +04:00
|
|
|
}
|
|
|
|
|
2021-08-24 04:29:42 +03:00
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_repaint_failed(struct weston_output *output)
|
|
|
|
{
|
|
|
|
weston_log("Clearing repaint status.\n");
|
|
|
|
assert(output->repaint_status == REPAINT_AWAITING_COMPLETION);
|
|
|
|
output->repaint_status = REPAINT_NOT_SCHEDULED;
|
|
|
|
}
|
|
|
|
|
2012-03-06 04:50:08 +04:00
|
|
|
static void
|
|
|
|
idle_repaint(void *data)
|
|
|
|
{
|
|
|
|
struct weston_output *output = data;
|
2019-06-30 16:51:10 +03:00
|
|
|
int ret;
|
2012-03-06 04:50:08 +04:00
|
|
|
|
2017-03-03 19:59:42 +03:00
|
|
|
assert(output->repaint_status == REPAINT_BEGIN_FROM_IDLE);
|
|
|
|
output->repaint_status = REPAINT_AWAITING_COMPLETION;
|
2017-10-26 14:33:59 +03:00
|
|
|
output->idle_repaint_source = NULL;
|
2019-06-30 16:51:10 +03:00
|
|
|
ret = output->start_repaint_loop(output);
|
|
|
|
if (ret != 0)
|
|
|
|
weston_output_schedule_repaint_reset(output);
|
2008-10-12 05:21:39 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_entry_insert(struct weston_layer_entry *list,
|
|
|
|
struct weston_layer_entry *entry)
|
|
|
|
{
|
|
|
|
wl_list_insert(&list->link, &entry->link);
|
|
|
|
entry->layer = list->layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_entry_remove(struct weston_layer_entry *entry)
|
|
|
|
{
|
|
|
|
wl_list_remove(&entry->link);
|
|
|
|
wl_list_init(&entry->link);
|
|
|
|
entry->layer = NULL;
|
|
|
|
}
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
|
|
|
|
/** Initialize the weston_layer struct.
|
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
|
|
|
* \param layer The layer to initialize
|
|
|
|
*/
|
2012-02-29 21:42:35 +04:00
|
|
|
WL_EXPORT void
|
2016-12-17 15:40:51 +03:00
|
|
|
weston_layer_init(struct weston_layer *layer,
|
|
|
|
struct weston_compositor *compositor)
|
2012-02-29 21:42:35 +04:00
|
|
|
{
|
2016-12-17 15:40:51 +03:00
|
|
|
layer->compositor = compositor;
|
|
|
|
wl_list_init(&layer->link);
|
2014-07-09 23:12:56 +04:00
|
|
|
wl_list_init(&layer->view_list.link);
|
|
|
|
layer->view_list.layer = layer;
|
2014-07-09 23:12:57 +04:00
|
|
|
weston_layer_set_mask_infinite(layer);
|
2016-12-17 15:40:51 +03:00
|
|
|
}
|
|
|
|
|
2021-05-14 14:29:40 +03:00
|
|
|
/** Finalize the weston_layer struct.
|
|
|
|
*
|
|
|
|
* \param layer The layer to finalize.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_fini(struct weston_layer *layer)
|
|
|
|
{
|
|
|
|
wl_list_remove(&layer->link);
|
|
|
|
|
|
|
|
if (!wl_list_empty(&layer->view_list.link))
|
|
|
|
weston_log("BUG: finalizing a layer with views still on it.\n");
|
|
|
|
|
|
|
|
wl_list_remove(&layer->view_list.link);
|
|
|
|
}
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
/** Sets the position of the layer in the layer list. The layer will be placed
|
|
|
|
* below any layer with the same position value, if any.
|
|
|
|
* This function is safe to call if the layer is already on the list, but the
|
|
|
|
* layer may be moved below other layers at the same position, if any.
|
|
|
|
*
|
|
|
|
* \param layer The layer to modify
|
|
|
|
* \param position The position the layer will be placed at
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_set_position(struct weston_layer *layer,
|
|
|
|
enum weston_layer_position position)
|
|
|
|
{
|
|
|
|
struct weston_layer *below;
|
|
|
|
|
|
|
|
wl_list_remove(&layer->link);
|
|
|
|
|
|
|
|
/* layer_list is ordered from top to bottom, the last layer being the
|
|
|
|
* background with the smallest position value */
|
|
|
|
|
|
|
|
layer->position = position;
|
|
|
|
wl_list_for_each_reverse(below, &layer->compositor->layer_list, link) {
|
|
|
|
if (below->position >= layer->position) {
|
|
|
|
wl_list_insert(&below->link, &layer->link);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wl_list_insert(&layer->compositor->layer_list, &layer->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Hide a layer by taking it off the layer list.
|
|
|
|
* This function is safe to call if the layer is not on the list.
|
|
|
|
*
|
|
|
|
* \param layer The layer to hide
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_unset_position(struct weston_layer *layer)
|
|
|
|
{
|
|
|
|
wl_list_remove(&layer->link);
|
|
|
|
wl_list_init(&layer->link);
|
2012-02-29 21:42:35 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 23:12:57 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_set_mask(struct weston_layer *layer,
|
|
|
|
int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
struct weston_view *view;
|
|
|
|
|
|
|
|
layer->mask.x1 = x;
|
|
|
|
layer->mask.x2 = x + width;
|
|
|
|
layer->mask.y1 = y;
|
|
|
|
layer->mask.y2 = y + height;
|
|
|
|
|
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_layer_set_mask_infinite(struct weston_layer *layer)
|
|
|
|
{
|
2019-10-16 23:02:59 +03:00
|
|
|
struct weston_view *view;
|
|
|
|
|
|
|
|
layer->mask.x1 = INT32_MIN;
|
|
|
|
layer->mask.x2 = INT32_MAX;
|
|
|
|
layer->mask.y1 = INT32_MIN;
|
|
|
|
layer->mask.y2 = INT32_MAX;
|
|
|
|
|
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
|
|
|
weston_view_geometry_dirty(view);
|
|
|
|
}
|
2014-07-09 23:12:57 +04:00
|
|
|
}
|
|
|
|
|
2018-07-20 10:38:25 +03:00
|
|
|
WL_EXPORT bool
|
|
|
|
weston_layer_mask_is_infinite(struct weston_layer *layer)
|
|
|
|
{
|
|
|
|
return layer->mask.x1 == INT32_MIN &&
|
|
|
|
layer->mask.y1 == INT32_MIN &&
|
2019-10-16 23:02:59 +03:00
|
|
|
layer->mask.x2 == INT32_MAX &&
|
|
|
|
layer->mask.y2 == INT32_MAX;
|
2018-07-20 10:38:25 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2011-04-23 21:04:11 +04:00
|
|
|
WL_EXPORT void
|
2012-06-20 08:35:59 +04:00
|
|
|
weston_output_schedule_repaint(struct weston_output *output)
|
2008-10-12 05:21:39 +04:00
|
|
|
{
|
2012-06-20 08:35:59 +04:00
|
|
|
struct weston_compositor *compositor = output->compositor;
|
2011-06-21 23:02:12 +04:00
|
|
|
struct wl_event_loop *loop;
|
2011-03-14 14:07:26 +03:00
|
|
|
|
2016-08-30 22:05:16 +03:00
|
|
|
if (compositor->state == WESTON_COMPOSITOR_SLEEPING ||
|
|
|
|
compositor->state == WESTON_COMPOSITOR_OFFSCREEN)
|
2011-04-22 22:01:18 +04:00
|
|
|
return;
|
|
|
|
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
if (!output->repaint_needed)
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(compositor, "core_repaint_req", TLP_OUTPUT(output), TLP_END);
|
compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.
The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.
To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.
The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.
A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr
The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
screen?
- How long does it take to process the scenegraph?
v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-12 16:09:24 +03:00
|
|
|
|
2011-06-21 23:02:12 +04:00
|
|
|
loop = wl_display_get_event_loop(compositor->wl_display);
|
2017-03-01 14:34:06 +03:00
|
|
|
output->repaint_needed = true;
|
2017-03-03 19:59:42 +03:00
|
|
|
|
|
|
|
/* If we already have a repaint scheduled for our idle handler,
|
|
|
|
* no need to set it again. If the repaint has been called but
|
|
|
|
* not finished, then weston_output_finish_frame() will notice
|
|
|
|
* that a repaint is needed and schedule one. */
|
|
|
|
if (output->repaint_status != REPAINT_NOT_SCHEDULED)
|
2012-06-20 08:35:59 +04:00
|
|
|
return;
|
2011-03-14 14:07:26 +03:00
|
|
|
|
2017-03-03 19:59:42 +03:00
|
|
|
output->repaint_status = REPAINT_BEGIN_FROM_IDLE;
|
2017-10-26 14:33:59 +03:00
|
|
|
assert(!output->idle_repaint_source);
|
|
|
|
output->idle_repaint_source = wl_event_loop_add_idle(loop, idle_repaint,
|
|
|
|
output);
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(compositor, "core_repaint_enter_loop", TLP_OUTPUT(output), TLP_END);
|
2008-10-12 05:21:39 +04:00
|
|
|
}
|
2009-02-09 23:17:46 +03:00
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_schedule_repaint
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2012-06-20 08:35:59 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_schedule_repaint(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link)
|
|
|
|
weston_output_schedule_repaint(output);
|
|
|
|
}
|
|
|
|
|
2008-11-06 18:38:17 +03:00
|
|
|
static void
|
2011-08-19 01:55:30 +04:00
|
|
|
surface_destroy(struct wl_client *client, struct wl_resource *resource)
|
2008-10-09 06:51:32 +04:00
|
|
|
{
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_resource_destroy(resource);
|
2008-10-09 06:51:32 +04:00
|
|
|
}
|
|
|
|
|
2012-03-27 18:36:40 +04:00
|
|
|
static void
|
|
|
|
surface_attach(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *buffer_resource, int32_t sx, int32_t sy)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2022-01-14 04:02:21 +03:00
|
|
|
struct weston_compositor *ec = surface->compositor;
|
2013-06-21 05:38:23 +04:00
|
|
|
struct weston_buffer *buffer = NULL;
|
2012-03-27 18:36:40 +04:00
|
|
|
|
2013-08-20 22:30:54 +04:00
|
|
|
if (buffer_resource) {
|
2022-01-14 04:02:21 +03:00
|
|
|
buffer = weston_buffer_from_resource(ec, buffer_resource);
|
2013-08-20 22:30:54 +04:00
|
|
|
if (buffer == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
2013-08-15 23:26:42 +04:00
|
|
|
}
|
2011-06-24 05:43:50 +04:00
|
|
|
|
compositor: introduce weston_buffer_reference
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-04 17:58:12 +04:00
|
|
|
/* Attach, attach, without commit in between does not send
|
|
|
|
* wl_buffer.release. */
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_set_buffer(&surface->pending, buffer);
|
2012-03-27 18:36:40 +04:00
|
|
|
|
2012-10-10 13:49:23 +04:00
|
|
|
surface->pending.sx = sx;
|
|
|
|
surface->pending.sy = sy;
|
2013-02-21 14:29:21 +04:00
|
|
|
surface->pending.newly_attached = 1;
|
2008-10-09 06:51:32 +04:00
|
|
|
}
|
|
|
|
|
2012-04-11 17:19:37 +04:00
|
|
|
static void
|
|
|
|
surface_damage(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2012-04-11 17:19:37 +04:00
|
|
|
|
2015-11-17 23:11:35 +03:00
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
return;
|
|
|
|
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_union_rect(&surface->pending.damage_surface,
|
|
|
|
&surface->pending.damage_surface,
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_damage_buffer(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pixman_region32_union_rect(&surface->pending.damage_buffer,
|
|
|
|
&surface->pending.damage_buffer,
|
2012-06-18 23:09:11 +04:00
|
|
|
x, y, width, height);
|
2008-11-29 01:06:06 +03:00
|
|
|
}
|
|
|
|
|
2011-08-17 07:01:28 +04:00
|
|
|
static void
|
2011-08-19 01:55:30 +04:00
|
|
|
destroy_frame_callback(struct wl_resource *resource)
|
2011-08-17 07:01:28 +04:00
|
|
|
{
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
2011-08-17 07:01:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_frame(struct wl_client *client,
|
2011-08-19 01:55:30 +04:00
|
|
|
struct wl_resource *resource, uint32_t callback)
|
2011-08-17 07:01:28 +04:00
|
|
|
{
|
2021-07-29 11:16:51 +03:00
|
|
|
struct wl_resource *cb;
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2011-08-17 07:01:28 +04:00
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
cb = wl_resource_create(client, &wl_callback_interface, 1, callback);
|
2011-08-17 07:01:28 +04:00
|
|
|
if (cb == NULL) {
|
2011-09-01 17:54:57 +04:00
|
|
|
wl_resource_post_no_memory(resource);
|
2011-08-17 07:01:28 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-10-10 13:49:31 +04:00
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_resource_set_implementation(cb, NULL, NULL,
|
2013-06-28 05:17:02 +04:00
|
|
|
destroy_frame_callback);
|
2011-08-17 07:01:28 +04:00
|
|
|
|
2021-07-29 11:16:51 +03:00
|
|
|
wl_list_insert(surface->pending.frame_callback_list.prev,
|
|
|
|
wl_resource_get_link(cb));
|
2011-08-17 07:01:28 +04:00
|
|
|
}
|
|
|
|
|
2012-02-24 01:11:59 +04:00
|
|
|
static void
|
|
|
|
surface_set_opaque_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2012-02-24 01:11:59 +04:00
|
|
|
struct weston_region *region;
|
|
|
|
|
|
|
|
if (region_resource) {
|
2013-06-14 19:07:56 +04:00
|
|
|
region = wl_resource_get_user_data(region_resource);
|
2012-10-10 13:49:27 +04:00
|
|
|
pixman_region32_copy(&surface->pending.opaque,
|
|
|
|
®ion->region);
|
2012-02-24 01:11:59 +04:00
|
|
|
} else {
|
2014-06-26 21:37:36 +04:00
|
|
|
pixman_region32_clear(&surface->pending.opaque);
|
2012-02-24 01:11:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_set_input_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2012-02-24 02:30:45 +04:00
|
|
|
struct weston_region *region;
|
2012-02-24 01:11:59 +04:00
|
|
|
|
|
|
|
if (region_resource) {
|
2013-06-14 19:07:56 +04:00
|
|
|
region = wl_resource_get_user_data(region_resource);
|
2012-10-10 13:49:28 +04:00
|
|
|
pixman_region32_copy(&surface->pending.input,
|
|
|
|
®ion->region);
|
2012-02-24 01:11:59 +04:00
|
|
|
} else {
|
2012-10-10 13:49:28 +04:00
|
|
|
pixman_region32_fini(&surface->pending.input);
|
|
|
|
region_init_infinite(&surface->pending.input);
|
2012-02-24 01:11:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-27 19:30:29 +03:00
|
|
|
/* Cause damage to this sub-surface and all its children.
|
|
|
|
*
|
|
|
|
* This is useful when there are state changes that need an implicit
|
|
|
|
* damage, e.g. a z-order change.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_surface_damage_subsurfaces(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *child;
|
|
|
|
|
|
|
|
weston_surface_damage(sub->surface);
|
|
|
|
sub->reordered = false;
|
|
|
|
|
|
|
|
wl_list_for_each(child, &sub->surface->subsurface_list, parent_link)
|
|
|
|
if (child != sub)
|
|
|
|
weston_surface_damage_subsurfaces(child);
|
|
|
|
}
|
|
|
|
|
2012-10-10 13:49:23 +04:00
|
|
|
static void
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
weston_surface_commit_subsurface_order(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
|
|
|
|
wl_list_for_each_reverse(sub, &surface->subsurface_list_pending,
|
|
|
|
parent_link_pending) {
|
|
|
|
wl_list_remove(&sub->parent_link);
|
|
|
|
wl_list_insert(&surface->subsurface_list, &sub->parent_link);
|
2017-01-27 19:30:29 +03:00
|
|
|
|
|
|
|
if (sub->reordered)
|
|
|
|
weston_surface_damage_subsurfaces(sub);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-16 19:55:19 +04:00
|
|
|
static void
|
2016-04-26 15:50:58 +03:00
|
|
|
weston_surface_build_buffer_matrix(const struct weston_surface *surface,
|
2014-10-16 19:55:19 +04:00
|
|
|
struct weston_matrix *matrix)
|
|
|
|
{
|
2016-04-26 15:50:58 +03:00
|
|
|
const struct weston_buffer_viewport *vp = &surface->buffer_viewport;
|
2014-10-16 19:55:19 +04:00
|
|
|
double src_width, src_height, dest_width, dest_height;
|
|
|
|
|
|
|
|
weston_matrix_init(matrix);
|
|
|
|
|
|
|
|
if (vp->buffer.src_width == wl_fixed_from_int(-1)) {
|
|
|
|
src_width = surface->width_from_buffer;
|
|
|
|
src_height = surface->height_from_buffer;
|
|
|
|
} else {
|
|
|
|
src_width = wl_fixed_to_double(vp->buffer.src_width);
|
|
|
|
src_height = wl_fixed_to_double(vp->buffer.src_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vp->surface.width == -1) {
|
|
|
|
dest_width = src_width;
|
|
|
|
dest_height = src_height;
|
|
|
|
} else {
|
|
|
|
dest_width = vp->surface.width;
|
|
|
|
dest_height = vp->surface.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src_width != dest_width || src_height != dest_height)
|
|
|
|
weston_matrix_scale(matrix,
|
|
|
|
src_width / dest_width,
|
|
|
|
src_height / dest_height, 1);
|
|
|
|
|
|
|
|
if (vp->buffer.src_width != wl_fixed_from_int(-1))
|
|
|
|
weston_matrix_translate(matrix,
|
|
|
|
wl_fixed_to_double(vp->buffer.src_x),
|
|
|
|
wl_fixed_to_double(vp->buffer.src_y),
|
|
|
|
0);
|
|
|
|
|
|
|
|
switch (vp->buffer.transform) {
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
|
|
|
weston_matrix_scale(matrix, -1, 1, 1);
|
|
|
|
weston_matrix_translate(matrix,
|
|
|
|
surface->width_from_buffer, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (vp->buffer.transform) {
|
|
|
|
default:
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
weston_matrix_rotate_xy(matrix, 0, -1);
|
2014-10-16 19:55:19 +04:00
|
|
|
weston_matrix_translate(matrix,
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
0, surface->width_from_buffer, 0);
|
2014-10-16 19:55:19 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
weston_matrix_rotate_xy(matrix, -1, 0);
|
|
|
|
weston_matrix_translate(matrix,
|
|
|
|
surface->width_from_buffer,
|
|
|
|
surface->height_from_buffer, 0);
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
weston_matrix_rotate_xy(matrix, 0, 1);
|
2014-10-16 19:55:19 +04:00
|
|
|
weston_matrix_translate(matrix,
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
surface->height_from_buffer, 0, 0);
|
2014-10-16 19:55:19 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_matrix_scale(matrix, vp->buffer.scale, vp->buffer.scale, 1);
|
|
|
|
}
|
|
|
|
|
2016-04-26 13:46:38 +03:00
|
|
|
/**
|
|
|
|
* Compute a + b > c while being safe to overflows.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
fixed_sum_gt(wl_fixed_t a, wl_fixed_t b, wl_fixed_t c)
|
|
|
|
{
|
|
|
|
return (int64_t)a + (int64_t)b > (int64_t)c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
weston_surface_is_pending_viewport_source_valid(
|
|
|
|
const struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
const struct weston_surface_state *pend = &surface->pending;
|
|
|
|
const struct weston_buffer_viewport *vp = &pend->buffer_viewport;
|
|
|
|
int width_from_buffer = 0;
|
|
|
|
int height_from_buffer = 0;
|
|
|
|
wl_fixed_t w;
|
|
|
|
wl_fixed_t h;
|
|
|
|
|
|
|
|
/* If viewport source rect is not set, it is always ok. */
|
|
|
|
if (vp->buffer.src_width == wl_fixed_from_int(-1))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (pend->newly_attached) {
|
|
|
|
if (pend->buffer) {
|
|
|
|
convert_size_by_transform_scale(&width_from_buffer,
|
|
|
|
&height_from_buffer,
|
|
|
|
pend->buffer->width,
|
|
|
|
pend->buffer->height,
|
|
|
|
vp->buffer.transform,
|
|
|
|
vp->buffer.scale);
|
|
|
|
} else {
|
|
|
|
/* No buffer: viewport is irrelevant. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
width_from_buffer = surface->width_from_buffer;
|
|
|
|
height_from_buffer = surface->height_from_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert((width_from_buffer == 0) == (height_from_buffer == 0));
|
|
|
|
assert(width_from_buffer >= 0 && height_from_buffer >= 0);
|
|
|
|
|
|
|
|
/* No buffer: viewport is irrelevant. */
|
|
|
|
if (width_from_buffer == 0 || height_from_buffer == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/* overflow checks for wl_fixed_from_int() */
|
|
|
|
if (width_from_buffer > wl_fixed_to_int(INT32_MAX))
|
|
|
|
return false;
|
|
|
|
if (height_from_buffer > wl_fixed_to_int(INT32_MAX))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
w = wl_fixed_from_int(width_from_buffer);
|
|
|
|
h = wl_fixed_from_int(height_from_buffer);
|
|
|
|
|
|
|
|
if (fixed_sum_gt(vp->buffer.src_x, vp->buffer.src_width, w))
|
|
|
|
return false;
|
|
|
|
if (fixed_sum_gt(vp->buffer.src_y, vp->buffer.src_height, h))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-26 14:28:28 +03:00
|
|
|
static bool
|
|
|
|
fixed_is_integer(wl_fixed_t v)
|
|
|
|
{
|
|
|
|
return (v & 0xff) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
weston_surface_is_pending_viewport_dst_size_int(
|
|
|
|
const struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
const struct weston_buffer_viewport *vp =
|
|
|
|
&surface->pending.buffer_viewport;
|
|
|
|
|
|
|
|
if (vp->surface.width != -1) {
|
|
|
|
assert(vp->surface.width > 0 && vp->surface.height > 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fixed_is_integer(vp->buffer.src_width) &&
|
|
|
|
fixed_is_integer(vp->buffer.src_height);
|
|
|
|
}
|
|
|
|
|
2015-11-26 23:17:48 +03:00
|
|
|
/* Translate pending damage in buffer co-ordinates to surface
|
|
|
|
* co-ordinates and union it with a pixman_region32_t.
|
|
|
|
* This should only be called after the buffer is attached.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
apply_damage_buffer(pixman_region32_t *dest,
|
|
|
|
struct weston_surface *surface,
|
|
|
|
struct weston_surface_state *state)
|
|
|
|
{
|
|
|
|
struct weston_buffer *buffer = surface->buffer_ref.buffer;
|
|
|
|
|
|
|
|
/* wl_surface.damage_buffer needs to be clipped to the buffer,
|
|
|
|
* translated into surface co-ordinates and unioned with
|
|
|
|
* any other surface damage.
|
|
|
|
* None of this makes sense if there is no buffer though.
|
|
|
|
*/
|
|
|
|
if (buffer && pixman_region32_not_empty(&state->damage_buffer)) {
|
|
|
|
pixman_region32_t buffer_damage;
|
|
|
|
|
|
|
|
pixman_region32_intersect_rect(&state->damage_buffer,
|
|
|
|
&state->damage_buffer,
|
|
|
|
0, 0, buffer->width,
|
|
|
|
buffer->height);
|
|
|
|
pixman_region32_init(&buffer_damage);
|
|
|
|
weston_matrix_transform_region(&buffer_damage,
|
|
|
|
&surface->buffer_to_surface_matrix,
|
|
|
|
&state->damage_buffer);
|
|
|
|
pixman_region32_union(dest, dest, &buffer_damage);
|
|
|
|
pixman_region32_fini(&buffer_damage);
|
|
|
|
}
|
|
|
|
/* We should clear this on commit even if there was no buffer */
|
|
|
|
pixman_region32_clear(&state->damage_buffer);
|
|
|
|
}
|
|
|
|
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
static void
|
|
|
|
weston_surface_set_desired_protection(struct weston_surface *surface,
|
|
|
|
enum weston_hdcp_protection protection)
|
|
|
|
{
|
|
|
|
if (surface->desired_protection == protection)
|
|
|
|
return;
|
|
|
|
surface->desired_protection = protection;
|
|
|
|
weston_surface_damage(surface);
|
|
|
|
}
|
|
|
|
|
2019-03-28 12:35:42 +03:00
|
|
|
static void
|
|
|
|
weston_surface_set_protection_mode(struct weston_surface *surface,
|
|
|
|
enum weston_surface_protection_mode p_mode)
|
|
|
|
{
|
|
|
|
struct content_protection *cp = surface->compositor->content_protection;
|
|
|
|
struct protected_surface *psurface;
|
|
|
|
|
|
|
|
surface->protection_mode = p_mode;
|
|
|
|
wl_list_for_each(psurface, &cp->protected_list, link) {
|
|
|
|
if (!psurface || psurface->surface != surface)
|
|
|
|
continue;
|
|
|
|
weston_protected_surface_send_event(psurface,
|
|
|
|
surface->current_protection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_commit_state(struct weston_surface *surface,
|
|
|
|
struct weston_surface_state *state)
|
2012-10-10 13:49:23 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
2012-10-30 19:44:01 +04:00
|
|
|
pixman_region32_t opaque;
|
|
|
|
|
2013-05-22 16:41:37 +04:00
|
|
|
/* wl_surface.set_buffer_transform */
|
|
|
|
/* wl_surface.set_buffer_scale */
|
2016-04-15 14:47:08 +03:00
|
|
|
/* wp_viewport.set_source */
|
|
|
|
/* wp_viewport.set_destination */
|
2014-05-20 23:33:03 +04:00
|
|
|
surface->buffer_viewport = state->buffer_viewport;
|
2013-05-22 16:41:37 +04:00
|
|
|
|
2012-10-10 13:49:23 +04:00
|
|
|
/* wl_surface.attach */
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
if (state->newly_attached) {
|
|
|
|
/* zwp_surface_synchronization_v1.set_acquire_fence */
|
|
|
|
fd_move(&surface->acquire_fence_fd,
|
|
|
|
&state->acquire_fence_fd);
|
2018-10-19 12:14:11 +03:00
|
|
|
/* zwp_surface_synchronization_v1.get_release */
|
|
|
|
weston_buffer_release_move(&surface->buffer_release_ref,
|
|
|
|
&state->buffer_release_ref);
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_attach(surface, state->buffer);
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
}
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_set_buffer(state, NULL);
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
assert(state->acquire_fence_fd == -1);
|
2018-10-19 12:14:11 +03:00
|
|
|
assert(state->buffer_release_ref.buffer_release == NULL);
|
2013-02-21 14:29:21 +04:00
|
|
|
|
2014-10-16 19:55:19 +04:00
|
|
|
weston_surface_build_buffer_matrix(surface,
|
|
|
|
&surface->surface_to_buffer_matrix);
|
|
|
|
weston_matrix_invert(&surface->buffer_to_surface_matrix,
|
|
|
|
&surface->surface_to_buffer_matrix);
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
if (state->newly_attached || state->buffer_viewport.changed) {
|
2014-06-13 20:14:20 +04:00
|
|
|
weston_surface_update_size(surface);
|
2016-08-12 11:41:33 +03:00
|
|
|
if (surface->committed)
|
|
|
|
surface->committed(surface, state->sx, state->sy);
|
2014-06-13 20:14:20 +04:00
|
|
|
}
|
2013-02-21 14:29:21 +04:00
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
state->sx = 0;
|
|
|
|
state->sy = 0;
|
|
|
|
state->newly_attached = 0;
|
|
|
|
state->buffer_viewport.changed = 0;
|
2012-10-10 13:49:25 +04:00
|
|
|
|
2015-11-26 23:17:48 +03:00
|
|
|
/* wl_surface.damage and wl_surface.damage_buffer */
|
2019-09-05 13:12:18 +03:00
|
|
|
if (pixman_region32_not_empty(&state->damage_surface) ||
|
|
|
|
pixman_region32_not_empty(&state->damage_buffer))
|
2019-09-05 14:56:12 +03:00
|
|
|
TL_POINT(surface->compositor, "core_commit_damage", TLP_SURFACE(surface), TLP_END);
|
2015-11-26 23:17:48 +03:00
|
|
|
|
2012-10-10 13:49:25 +04:00
|
|
|
pixman_region32_union(&surface->damage, &surface->damage,
|
2015-11-26 23:17:48 +03:00
|
|
|
&state->damage_surface);
|
|
|
|
|
|
|
|
apply_damage_buffer(&surface->damage, surface, state);
|
|
|
|
|
2012-11-08 20:36:02 +04:00
|
|
|
pixman_region32_intersect_rect(&surface->damage, &surface->damage,
|
2014-06-26 21:37:36 +04:00
|
|
|
0, 0, surface->width, surface->height);
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_clear(&state->damage_surface);
|
2012-10-10 13:49:27 +04:00
|
|
|
|
|
|
|
/* wl_surface.set_opaque_region */
|
2014-05-20 23:33:03 +04:00
|
|
|
pixman_region32_init(&opaque);
|
|
|
|
pixman_region32_intersect_rect(&opaque, &state->opaque,
|
|
|
|
0, 0, surface->width, surface->height);
|
2012-10-30 19:44:01 +04:00
|
|
|
|
|
|
|
if (!pixman_region32_equal(&opaque, &surface->opaque)) {
|
|
|
|
pixman_region32_copy(&surface->opaque, &opaque);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
|
|
|
weston_view_geometry_dirty(view);
|
2012-10-30 19:44:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_fini(&opaque);
|
2012-10-10 13:49:28 +04:00
|
|
|
|
|
|
|
/* wl_surface.set_input_region */
|
2014-05-20 23:33:03 +04:00
|
|
|
pixman_region32_intersect_rect(&surface->input, &state->input,
|
|
|
|
0, 0, surface->width, surface->height);
|
2012-10-10 13:49:28 +04:00
|
|
|
|
2012-10-10 13:49:31 +04:00
|
|
|
/* wl_surface.frame */
|
|
|
|
wl_list_insert_list(&surface->frame_callback_list,
|
2014-05-20 23:33:03 +04:00
|
|
|
&state->frame_callback_list);
|
|
|
|
wl_list_init(&state->frame_callback_list);
|
2014-09-24 06:08:46 +04:00
|
|
|
|
|
|
|
/* XXX:
|
|
|
|
* What should happen with a feedback request, if there
|
|
|
|
* is no wl_buffer attached for this commit?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* presentation.feedback */
|
|
|
|
wl_list_insert_list(&surface->feedback_list,
|
|
|
|
&state->feedback_list);
|
|
|
|
wl_list_init(&state->feedback_list);
|
2016-07-22 12:48:03 +03:00
|
|
|
|
2019-03-28 12:35:42 +03:00
|
|
|
/* weston_protected_surface.enforced/relaxed */
|
|
|
|
if (surface->protection_mode != state->protection_mode)
|
|
|
|
weston_surface_set_protection_mode(surface,
|
|
|
|
state->protection_mode);
|
|
|
|
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
/* weston_protected_surface.set_type */
|
|
|
|
weston_surface_set_desired_protection(surface, state->desired_protection);
|
|
|
|
|
2016-07-22 12:48:03 +03:00
|
|
|
wl_signal_emit(&surface->commit_signal, surface);
|
2014-05-20 23:33:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_surface_commit(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
weston_surface_commit_state(surface, &surface->pending);
|
2012-10-10 13:49:31 +04:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
weston_surface_commit_subsurface_order(surface);
|
|
|
|
|
2012-10-10 13:49:28 +04:00
|
|
|
weston_surface_schedule_repaint(surface);
|
2012-10-10 13:49:23 +04:00
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
|
|
|
weston_subsurface_commit(struct weston_subsurface *sub);
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_parent_commit(struct weston_subsurface *sub,
|
|
|
|
int parent_is_synchronized);
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_commit(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);
|
|
|
|
|
2016-04-26 13:46:38 +03:00
|
|
|
if (!weston_surface_is_pending_viewport_source_valid(surface)) {
|
|
|
|
assert(surface->viewport_resource);
|
|
|
|
|
|
|
|
wl_resource_post_error(surface->viewport_resource,
|
|
|
|
WP_VIEWPORT_ERROR_OUT_OF_BUFFER,
|
|
|
|
"wl_surface@%d has viewport source outside buffer",
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-26 14:28:28 +03:00
|
|
|
if (!weston_surface_is_pending_viewport_dst_size_int(surface)) {
|
|
|
|
assert(surface->viewport_resource);
|
|
|
|
|
|
|
|
wl_resource_post_error(surface->viewport_resource,
|
|
|
|
WP_VIEWPORT_ERROR_BAD_SIZE,
|
|
|
|
"wl_surface@%d viewport dst size not integer",
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
if (surface->pending.acquire_fence_fd >= 0) {
|
|
|
|
assert(surface->synchronization_resource);
|
|
|
|
|
|
|
|
if (!surface->pending.buffer) {
|
|
|
|
fd_clear(&surface->pending.acquire_fence_fd);
|
|
|
|
wl_resource_post_error(surface->synchronization_resource,
|
|
|
|
ZWP_LINUX_SURFACE_SYNCHRONIZATION_V1_ERROR_NO_BUFFER,
|
|
|
|
"wl_surface@%"PRIu32" no buffer for synchronization",
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-14 04:36:54 +03:00
|
|
|
if (surface->pending.buffer->type == WESTON_BUFFER_SHM) {
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
fd_clear(&surface->pending.acquire_fence_fd);
|
|
|
|
wl_resource_post_error(surface->synchronization_resource,
|
|
|
|
ZWP_LINUX_SURFACE_SYNCHRONIZATION_V1_ERROR_UNSUPPORTED_BUFFER,
|
|
|
|
"wl_surface@%"PRIu32" unsupported buffer for synchronization",
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-19 12:14:11 +03:00
|
|
|
if (surface->pending.buffer_release_ref.buffer_release &&
|
|
|
|
!surface->pending.buffer) {
|
|
|
|
assert(surface->synchronization_resource);
|
|
|
|
|
|
|
|
wl_resource_post_error(surface->synchronization_resource,
|
|
|
|
ZWP_LINUX_SURFACE_SYNCHRONIZATION_V1_ERROR_NO_BUFFER,
|
|
|
|
"wl_surface@%"PRIu32" no buffer for synchronization",
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (sub) {
|
|
|
|
weston_subsurface_commit(sub);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_surface_commit(surface);
|
|
|
|
|
|
|
|
wl_list_for_each(sub, &surface->subsurface_list, parent_link) {
|
|
|
|
if (sub->surface != surface)
|
|
|
|
weston_subsurface_parent_commit(sub, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-27 19:03:42 +04:00
|
|
|
static void
|
|
|
|
surface_set_buffer_transform(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int transform)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2012-11-27 19:03:42 +04:00
|
|
|
|
2014-05-30 14:07:15 +04:00
|
|
|
/* if wl_output.transform grows more members this will need to be updated. */
|
|
|
|
if (transform < 0 ||
|
|
|
|
transform > WL_OUTPUT_TRANSFORM_FLIPPED_270) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_SURFACE_ERROR_INVALID_TRANSFORM,
|
|
|
|
"buffer transform must be a valid transform "
|
|
|
|
"('%d' specified)", transform);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-14 16:38:15 +04:00
|
|
|
surface->pending.buffer_viewport.buffer.transform = transform;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2012-11-27 19:03:42 +04:00
|
|
|
}
|
|
|
|
|
2013-05-22 16:41:37 +04:00
|
|
|
static void
|
|
|
|
surface_set_buffer_scale(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
2013-05-24 15:09:43 +04:00
|
|
|
int32_t scale)
|
2013-05-22 16:41:37 +04:00
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface = wl_resource_get_user_data(resource);
|
2013-05-22 16:41:37 +04:00
|
|
|
|
2014-05-30 14:07:15 +04:00
|
|
|
if (scale < 1) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_SURFACE_ERROR_INVALID_SCALE,
|
|
|
|
"buffer scale must be at least one "
|
|
|
|
"('%d' specified)", scale);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-14 16:38:15 +04:00
|
|
|
surface->pending.buffer_viewport.buffer.scale = scale;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2013-05-22 16:41:37 +04:00
|
|
|
}
|
|
|
|
|
2012-03-30 19:52:39 +04:00
|
|
|
static const struct wl_surface_interface surface_interface = {
|
2008-12-16 04:35:24 +03:00
|
|
|
surface_destroy,
|
|
|
|
surface_attach,
|
2011-08-17 07:01:28 +04:00
|
|
|
surface_damage,
|
2012-02-24 01:11:59 +04:00
|
|
|
surface_frame,
|
|
|
|
surface_set_opaque_region,
|
2012-10-10 13:49:23 +04:00
|
|
|
surface_set_input_region,
|
2012-11-27 19:03:42 +04:00
|
|
|
surface_commit,
|
2013-05-22 16:41:37 +04:00
|
|
|
surface_set_buffer_transform,
|
2015-11-26 23:17:48 +03:00
|
|
|
surface_set_buffer_scale,
|
|
|
|
surface_damage_buffer
|
2008-12-16 04:35:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
compositor_create_surface(struct wl_client *client,
|
2011-08-19 01:55:30 +04:00
|
|
|
struct wl_resource *resource, uint32_t id)
|
2008-11-07 16:39:37 +03:00
|
|
|
{
|
2013-06-25 23:34:33 +04:00
|
|
|
struct weston_compositor *ec = wl_resource_get_user_data(resource);
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_surface *surface;
|
2008-11-07 16:39:37 +03:00
|
|
|
|
2012-01-27 20:58:31 +04:00
|
|
|
surface = weston_surface_create(ec);
|
2021-01-19 01:36:48 +03:00
|
|
|
if (surface == NULL)
|
|
|
|
goto err;
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
surface->resource =
|
|
|
|
wl_resource_create(client, &wl_surface_interface,
|
|
|
|
wl_resource_get_version(resource), id);
|
2021-01-19 01:36:48 +03:00
|
|
|
if (surface->resource == NULL)
|
2022-05-04 19:04:55 +03:00
|
|
|
goto err_res;
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(surface->resource, &surface_interface,
|
|
|
|
surface, destroy_surface);
|
2014-04-07 09:04:50 +04:00
|
|
|
|
|
|
|
wl_signal_emit(&ec->create_surface_signal, surface);
|
2021-01-19 01:36:48 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
2022-05-04 19:04:55 +03:00
|
|
|
err_res:
|
2022-02-07 11:59:41 +03:00
|
|
|
weston_surface_unref(surface);
|
2021-01-19 01:36:48 +03:00
|
|
|
err:
|
|
|
|
wl_resource_post_no_memory(resource);
|
2008-12-16 04:35:24 +03:00
|
|
|
}
|
|
|
|
|
2012-02-24 01:11:59 +04:00
|
|
|
static void
|
|
|
|
destroy_region(struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:07:56 +04:00
|
|
|
struct weston_region *region = wl_resource_get_user_data(resource);
|
2012-02-24 01:11:59 +04:00
|
|
|
|
|
|
|
pixman_region32_fini(®ion->region);
|
|
|
|
free(region);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
region_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
2012-04-12 06:42:15 +04:00
|
|
|
wl_resource_destroy(resource);
|
2012-02-24 01:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
region_add(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
|
|
{
|
2013-06-14 19:07:56 +04:00
|
|
|
struct weston_region *region = wl_resource_get_user_data(resource);
|
2012-02-24 01:11:59 +04:00
|
|
|
|
|
|
|
pixman_region32_union_rect(®ion->region, ®ion->region,
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
region_subtract(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
|
|
{
|
2013-06-14 19:07:56 +04:00
|
|
|
struct weston_region *region = wl_resource_get_user_data(resource);
|
2012-02-24 01:11:59 +04:00
|
|
|
pixman_region32_t rect;
|
|
|
|
|
|
|
|
pixman_region32_init_rect(&rect, x, y, width, height);
|
|
|
|
pixman_region32_subtract(®ion->region, ®ion->region, &rect);
|
|
|
|
pixman_region32_fini(&rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_region_interface region_interface = {
|
|
|
|
region_destroy,
|
|
|
|
region_add,
|
|
|
|
region_subtract
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
compositor_create_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t id)
|
|
|
|
{
|
|
|
|
struct weston_region *region;
|
|
|
|
|
|
|
|
region = malloc(sizeof *region);
|
|
|
|
if (region == NULL) {
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_init(®ion->region);
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
region->resource =
|
|
|
|
wl_resource_create(client, &wl_region_interface, 1, id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (region->resource == NULL) {
|
|
|
|
free(region);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(region->resource, ®ion_interface,
|
|
|
|
region, destroy_region);
|
2012-02-24 01:11:59 +04:00
|
|
|
}
|
|
|
|
|
2012-03-30 19:52:39 +04:00
|
|
|
static const struct wl_compositor_interface compositor_interface = {
|
2008-12-16 04:35:24 +03:00
|
|
|
compositor_create_surface,
|
2012-02-24 01:11:59 +04:00
|
|
|
compositor_create_region
|
2008-12-16 04:35:24 +03:00
|
|
|
};
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
|
|
|
weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = sub->surface;
|
2014-06-13 20:14:20 +04:00
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_commit_state(surface, &sub->cached);
|
2022-01-15 06:12:53 +03:00
|
|
|
weston_buffer_reference(&sub->cached_buffer_ref, NULL,
|
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
weston_surface_commit_subsurface_order(surface);
|
|
|
|
|
|
|
|
weston_surface_schedule_repaint(surface);
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
sub->has_cached_data = 0;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = sub->surface;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this commit would cause the surface to move by the
|
|
|
|
* attach(dx, dy) parameters, the old damage region must be
|
|
|
|
* translated to correspond to the new surface coordinate system
|
2015-11-26 19:30:00 +03:00
|
|
|
* origin.
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
*/
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_translate(&sub->cached.damage_surface,
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
-surface->pending.sx, -surface->pending.sy);
|
2015-11-26 23:17:48 +03:00
|
|
|
pixman_region32_union(&sub->cached.damage_surface,
|
|
|
|
&sub->cached.damage_surface,
|
|
|
|
&surface->pending.damage_surface);
|
|
|
|
pixman_region32_clear(&surface->pending.damage_surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2021-12-31 17:49:34 +03:00
|
|
|
pixman_region32_union(&sub->cached.damage_buffer,
|
|
|
|
&sub->cached.damage_buffer,
|
|
|
|
&surface->pending.damage_buffer);
|
|
|
|
pixman_region32_clear(&surface->pending.damage_buffer);
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (surface->pending.newly_attached) {
|
|
|
|
sub->cached.newly_attached = 1;
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_set_buffer(&sub->cached,
|
|
|
|
surface->pending.buffer);
|
|
|
|
weston_buffer_reference(&sub->cached_buffer_ref,
|
2022-01-15 06:12:53 +03:00
|
|
|
surface->pending.buffer,
|
|
|
|
surface->pending.buffer ?
|
|
|
|
BUFFER_MAY_BE_ACCESSED :
|
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
2014-09-24 06:08:46 +04:00
|
|
|
weston_presentation_feedback_discard_list(
|
|
|
|
&sub->cached.feedback_list);
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
/* zwp_surface_synchronization_v1.set_acquire_fence */
|
|
|
|
fd_move(&sub->cached.acquire_fence_fd,
|
|
|
|
&surface->pending.acquire_fence_fd);
|
2018-10-19 12:14:11 +03:00
|
|
|
/* zwp_surface_synchronization_v1.get_release */
|
|
|
|
weston_buffer_release_move(&sub->cached.buffer_release_ref,
|
|
|
|
&surface->pending.buffer_release_ref);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.
As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.
While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.
This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-03-26 11:07:12 +03:00
|
|
|
sub->cached.desired_protection = surface->pending.desired_protection;
|
2019-03-28 12:35:42 +03:00
|
|
|
sub->cached.protection_mode = surface->pending.protection_mode;
|
libweston: Support zwp_surface_synchronization_v1.set_acquire_fence
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-19 12:14:11 +03:00
|
|
|
assert(surface->pending.acquire_fence_fd == -1);
|
2018-10-19 12:14:11 +03:00
|
|
|
assert(surface->pending.buffer_release_ref.buffer_release == NULL);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
sub->cached.sx += surface->pending.sx;
|
|
|
|
sub->cached.sy += surface->pending.sy;
|
2014-03-14 16:38:12 +04:00
|
|
|
|
2014-06-13 20:14:20 +04:00
|
|
|
sub->cached.buffer_viewport.changed |=
|
|
|
|
surface->pending.buffer_viewport.changed;
|
|
|
|
sub->cached.buffer_viewport.buffer =
|
|
|
|
surface->pending.buffer_viewport.buffer;
|
|
|
|
sub->cached.buffer_viewport.surface =
|
|
|
|
surface->pending.buffer_viewport.surface;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2014-06-13 20:14:20 +04:00
|
|
|
weston_surface_reset_pending_buffer(surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
pixman_region32_copy(&sub->cached.opaque, &surface->pending.opaque);
|
|
|
|
|
|
|
|
pixman_region32_copy(&sub->cached.input, &surface->pending.input);
|
|
|
|
|
|
|
|
wl_list_insert_list(&sub->cached.frame_callback_list,
|
|
|
|
&surface->pending.frame_callback_list);
|
|
|
|
wl_list_init(&surface->pending.frame_callback_list);
|
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
wl_list_insert_list(&sub->cached.feedback_list,
|
|
|
|
&surface->pending.feedback_list);
|
|
|
|
wl_list_init(&surface->pending.feedback_list);
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
sub->has_cached_data = 1;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
2014-10-03 22:13:42 +04:00
|
|
|
static bool
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
weston_subsurface_is_synchronized(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
while (sub) {
|
|
|
|
if (sub->synchronized)
|
2014-10-03 22:13:42 +04:00
|
|
|
return true;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
if (!sub->parent)
|
2014-10-03 22:13:42 +04:00
|
|
|
return false;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
sub = weston_surface_to_subsurface(sub->parent);
|
|
|
|
}
|
|
|
|
|
2014-11-04 16:38:39 +03:00
|
|
|
return false;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_commit(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = sub->surface;
|
|
|
|
struct weston_subsurface *tmp;
|
|
|
|
|
|
|
|
/* Recursive check for effectively synchronized. */
|
|
|
|
if (weston_subsurface_is_synchronized(sub)) {
|
|
|
|
weston_subsurface_commit_to_cache(sub);
|
|
|
|
} else {
|
2014-05-20 23:33:03 +04:00
|
|
|
if (sub->has_cached_data) {
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
/* flush accumulated state from cache */
|
|
|
|
weston_subsurface_commit_to_cache(sub);
|
|
|
|
weston_subsurface_commit_from_cache(sub);
|
|
|
|
} else {
|
|
|
|
weston_surface_commit(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(tmp, &surface->subsurface_list, parent_link) {
|
|
|
|
if (tmp->surface != surface)
|
|
|
|
weston_subsurface_parent_commit(tmp, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-17 17:46:05 +04:00
|
|
|
weston_subsurface_synchronized_commit(struct weston_subsurface *sub)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
{
|
|
|
|
struct weston_surface *surface = sub->surface;
|
|
|
|
struct weston_subsurface *tmp;
|
|
|
|
|
|
|
|
/* From now on, commit_from_cache the whole sub-tree, regardless of
|
|
|
|
* the synchronized mode of each child. This sub-surface or some
|
|
|
|
* of its ancestors were synchronized, so we are synchronized
|
|
|
|
* all the way down.
|
|
|
|
*/
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
if (sub->has_cached_data)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
weston_subsurface_commit_from_cache(sub);
|
|
|
|
|
|
|
|
wl_list_for_each(tmp, &surface->subsurface_list, parent_link) {
|
|
|
|
if (tmp->surface != surface)
|
|
|
|
weston_subsurface_parent_commit(tmp, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-17 17:46:05 +04:00
|
|
|
static void
|
|
|
|
weston_subsurface_parent_commit(struct weston_subsurface *sub,
|
|
|
|
int parent_is_synchronized)
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
2013-05-17 17:46:05 +04:00
|
|
|
if (sub->position.set) {
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(view, &sub->surface->views, surface_link)
|
|
|
|
weston_view_set_position(view,
|
|
|
|
sub->position.x,
|
|
|
|
sub->position.y);
|
|
|
|
|
2013-05-17 17:46:05 +04:00
|
|
|
sub->position.set = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent_is_synchronized || sub->synchronized)
|
|
|
|
weston_subsurface_synchronized_commit(sub);
|
|
|
|
}
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
static int
|
|
|
|
subsurface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return snprintf(buf, len, "sub-surface");
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
2016-08-12 11:41:33 +03:00
|
|
|
subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_for_each(view, &surface->views, surface_link)
|
2013-12-03 07:01:53 +04:00
|
|
|
weston_view_set_position(view,
|
|
|
|
view->geometry.x + dx,
|
|
|
|
view->geometry.y + dy);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
/* No need to check parent mappedness, because if parent is not
|
|
|
|
* mapped, parent is not in a visible layer, so this sub-surface
|
|
|
|
* will not be drawn either.
|
|
|
|
*/
|
2016-06-30 07:04:28 +03:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (!weston_surface_is_mapped(surface)) {
|
2022-01-27 00:04:52 +03:00
|
|
|
surface->is_mapped = surface->buffer_ref.buffer != NULL;
|
compositor: quick fix for sub-surface mapping
If a client does this:
1. create a main window and map it
2. create a wl_surface, and make it a sub-surface of the main window
3. set the sub-surface to desync
4. commit content to the sub-surface to map it
Then step 4 should cause the sub-surface to become mapped. However,
Weston fails to schedule a repaint in that case, so the sub-surface will
not appear until something else causes a repaint on that output, e.g.
the main window.
A quick and dirty fix is to set the output mask for the surface in
Weston, which allows the repaint to be scheduled. This patch implements
that, and might only work right on single-output systems.
A proper fix would involve rewriting the whole "is surface mapped"
mechanism in Weston, to not rely on output assignments but to have a
separate flag for "mapped", and figuring out how to schedule repaints
for the right outputs.
Following is the actual protocol sequence used to trigger the problem:
[3224648.125] -> wl_compositor@4.create_surface(new id wl_surface@3)
[3224648.206] -> xdg_shell@7.get_xdg_surface(new id xdg_surface@8, wl_surface@3)
[3224648.311] -> xdg_surface@8.set_title("simple-shm")
[3224648.378] -> wl_surface@3.damage(0, 0, 250, 250)
[3224649.888] -> wl_shm@6.create_pool(new id wl_shm_pool@9, fd 6, 250000)
[3224650.031] -> wl_shm_pool@9.create_buffer(new id wl_buffer@10, 0, 250, 250, 1000, 1)
[3224650.244] -> wl_shm_pool@9.destroy()
[3224651.975] -> wl_surface@3.attach(wl_buffer@10, 0, 0)
[3224652.100] -> wl_surface@3.damage(20, 20, 210, 210)
[3224652.243] -> wl_surface@3.frame(new id wl_callback@11)
[3224652.317] -> wl_surface@3.commit()
[3228652.535] -> wl_compositor@4.create_surface(new id wl_surface@12)
[3228652.610] -> wl_subcompositor@5.get_subsurface(new id wl_subsurface@13, wl_surface@12, wl_surface@3)
[3228652.644] -> wl_subsurface@13.set_desync()
[3228652.659] -> wl_subsurface@13.set_position(100, 100)
[3228654.090] -> wl_shm@6.create_pool(new id wl_shm_pool@14, fd 6, 250000)
[3228654.140] -> wl_shm_pool@14.create_buffer(new id wl_buffer@15, 0, 250, 250, 1000, 1)
[3228654.180] -> wl_shm_pool@14.destroy()
[3228654.408] -> wl_surface@12.attach(wl_buffer@15, 0, 0)
[3228654.436] -> wl_surface@12.damage(0, 0, 250, 250)
[3228654.462] -> wl_surface@12.commit()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: George Kiagiadakis <george.kiagiadakis@collabora.com>
Cc: Jason Ekstrand <jason.ekstrand@intel.com>
2014-06-30 12:52:07 +04:00
|
|
|
|
2014-09-11 00:37:33 +04:00
|
|
|
/* Cannot call weston_view_update_transform(),
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
* because that would call it also for the parent surface,
|
|
|
|
* which might not be mapped yet. That would lead to
|
|
|
|
* inconsistent state, where the window could never be
|
|
|
|
* mapped.
|
|
|
|
*
|
2016-06-30 07:04:28 +03:00
|
|
|
* Instead just force the is_mapped flag on, to make
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
* weston_surface_is_mapped() return true, so that when the
|
|
|
|
* parent surface does get mapped, this one will get
|
compositor: quick fix for sub-surface mapping
If a client does this:
1. create a main window and map it
2. create a wl_surface, and make it a sub-surface of the main window
3. set the sub-surface to desync
4. commit content to the sub-surface to map it
Then step 4 should cause the sub-surface to become mapped. However,
Weston fails to schedule a repaint in that case, so the sub-surface will
not appear until something else causes a repaint on that output, e.g.
the main window.
A quick and dirty fix is to set the output mask for the surface in
Weston, which allows the repaint to be scheduled. This patch implements
that, and might only work right on single-output systems.
A proper fix would involve rewriting the whole "is surface mapped"
mechanism in Weston, to not rely on output assignments but to have a
separate flag for "mapped", and figuring out how to schedule repaints
for the right outputs.
Following is the actual protocol sequence used to trigger the problem:
[3224648.125] -> wl_compositor@4.create_surface(new id wl_surface@3)
[3224648.206] -> xdg_shell@7.get_xdg_surface(new id xdg_surface@8, wl_surface@3)
[3224648.311] -> xdg_surface@8.set_title("simple-shm")
[3224648.378] -> wl_surface@3.damage(0, 0, 250, 250)
[3224649.888] -> wl_shm@6.create_pool(new id wl_shm_pool@9, fd 6, 250000)
[3224650.031] -> wl_shm_pool@9.create_buffer(new id wl_buffer@10, 0, 250, 250, 1000, 1)
[3224650.244] -> wl_shm_pool@9.destroy()
[3224651.975] -> wl_surface@3.attach(wl_buffer@10, 0, 0)
[3224652.100] -> wl_surface@3.damage(20, 20, 210, 210)
[3224652.243] -> wl_surface@3.frame(new id wl_callback@11)
[3224652.317] -> wl_surface@3.commit()
[3228652.535] -> wl_compositor@4.create_surface(new id wl_surface@12)
[3228652.610] -> wl_subcompositor@5.get_subsurface(new id wl_subsurface@13, wl_surface@12, wl_surface@3)
[3228652.644] -> wl_subsurface@13.set_desync()
[3228652.659] -> wl_subsurface@13.set_position(100, 100)
[3228654.090] -> wl_shm@6.create_pool(new id wl_shm_pool@14, fd 6, 250000)
[3228654.140] -> wl_shm_pool@14.create_buffer(new id wl_buffer@15, 0, 250, 250, 1000, 1)
[3228654.180] -> wl_shm_pool@14.destroy()
[3228654.408] -> wl_surface@12.attach(wl_buffer@15, 0, 0)
[3228654.436] -> wl_surface@12.damage(0, 0, 250, 250)
[3228654.462] -> wl_surface@12.commit()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: George Kiagiadakis <george.kiagiadakis@collabora.com>
Cc: Jason Ekstrand <jason.ekstrand@intel.com>
2014-06-30 12:52:07 +04:00
|
|
|
* included, too. See view_list_add().
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct weston_subsurface *
|
|
|
|
weston_surface_to_subsurface(struct weston_surface *surface)
|
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
if (surface->committed == subsurface_committed)
|
|
|
|
return surface->committed_private;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
shell: keyboard focus and restacking fixes for sub-surfaces
The shell needs to redirect some actions to the parent surface, when
they originally target a sub-surface. This patch implements the
following:
- Move, resize, and rotate bindings always target the parent surface.
- Opacity (full-surface alpha) binding targets the parent surface. This
is broken, because it should change the opacity of the whole compound
window, which is difficult to implement in the renderer.
- click_to_activate_binding() needs to check the shell surface type from
the main surface, because sub-surface would produce SHELL_SURFACE_NONE
and prevent activation.
- Also activate() needs to check the type from the main surface, and
restack the main surface. Keyboard focus is assigned to the original
(sub-)surface.
- focus_state_surface_destroy() needs to handle sub-surfaces: only the
main surface will be in a layer list. If the destroyed surface is
indeed a sub-surface, activate the main surface next. This way a
client that destroys a focused sub-surface still retains focus in the
same window.
- The workspace_manager.move_surface request can accept also
sub-surfaces, and it will move the corresponding main surface.
Changes in v2:
- do not special-case keyboard focus for sub-surfaces
- fix surface type checks for sub-surfaces in shell, fix restacking of
sub-surfaces in shell, fix focus_state_surface_destroy()
Changes in v3:
- Renamed weston_surface_get_parent() to
weston_surface_get_main_surface() to be more explicit that this is
about sub-surfaces
- Fixed move_surface_to_workspace() to handle keyboard focus on a
sub-surface.
- Used a temporary variable in several places to clarify code, instead
of reassigning a variable.
- Fixed workspace_manager_move_surface() to deal with sub-surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:44 +04:00
|
|
|
WL_EXPORT struct weston_surface *
|
|
|
|
weston_surface_get_main_surface(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
|
|
|
|
while (surface && (sub = weston_surface_to_subsurface(surface)))
|
|
|
|
surface = sub->parent;
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
compositor: send error for surface role resets
With the more accurate definition of wl_surface roles in Wayland,
enforce the restriction: a role is always set permanently, and
attempting to change it is a protocol error.
This patch is based on Jasper's patch:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016811.html
The difference in this patch compared to his are:
- send role errors on the interface whose request triggers it, not on
wl_surface
- an interface could have several requests assigning different roles,
cannot use wl_interface as the unique key; use an arbitary string
instead
- ensure in window-manager.c that create_shell_surface() ->
create_common_surface() is never called with surface->configure set,
to avoid compositor abort
- use wl_resource_post_no_memory() where appropriate instead of
hand-rolling it with wl_resource_post_error()
Ideally we would not add weston_surface::role_name field, but use
weston_surface::configure. At the moment this is not possible though,
because at least shell.c uses several different roles with the same
configure function. Drag'n'drop uses two configure functions for the
same role. The configure hook is also reset in several places,
which is not good for role tracking.
This patch overlooks the wl_surface roles assigned in privileged
extensions: screensaver, panel, background, lock, input panel.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-10-01 16:02:41 +04:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_surface_set_role(struct weston_surface *surface,
|
|
|
|
const char *role_name,
|
|
|
|
struct wl_resource *error_resource,
|
|
|
|
uint32_t error_code)
|
|
|
|
{
|
|
|
|
assert(role_name);
|
|
|
|
|
|
|
|
if (surface->role_name == NULL ||
|
|
|
|
surface->role_name == role_name ||
|
|
|
|
strcmp(surface->role_name, role_name) == 0) {
|
|
|
|
surface->role_name = role_name;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_post_error(error_resource, error_code,
|
|
|
|
"Cannot assign role %s to wl_surface@%d,"
|
|
|
|
" already has role %s\n",
|
|
|
|
role_name,
|
|
|
|
wl_resource_get_id(surface->resource),
|
|
|
|
surface->role_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:37 +03:00
|
|
|
WL_EXPORT const char *
|
|
|
|
weston_surface_get_role(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
return surface->role_name;
|
|
|
|
}
|
|
|
|
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_set_label_func(struct weston_surface *surface,
|
|
|
|
int (*desc)(struct weston_surface *,
|
|
|
|
char *, size_t))
|
|
|
|
{
|
|
|
|
surface->get_label = desc;
|
2019-10-15 13:25:41 +03:00
|
|
|
weston_timeline_refresh_subscription_objects(surface->compositor,
|
|
|
|
surface);
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
}
|
|
|
|
|
2015-02-09 14:16:57 +03:00
|
|
|
/** Get the size of surface contents
|
|
|
|
*
|
|
|
|
* \param surface The surface to query.
|
|
|
|
* \param width Returns the width of raw contents.
|
|
|
|
* \param height Returns the height of raw contents.
|
|
|
|
*
|
|
|
|
* Retrieves the raw surface content size in pixels for the given surface.
|
|
|
|
* This is the whole content size in buffer pixels. If the surface
|
2022-01-19 06:08:02 +03:00
|
|
|
* has no content, zeroes are returned.
|
2015-02-09 14:16:57 +03:00
|
|
|
*
|
|
|
|
* This function is used to determine the buffer size needed for
|
|
|
|
* a weston_surface_copy_content() call.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_surface_get_content_size(struct weston_surface *surface,
|
|
|
|
int *width, int *height)
|
|
|
|
{
|
2022-01-19 06:08:02 +03:00
|
|
|
struct weston_buffer *buffer = surface->buffer_ref.buffer;
|
2015-02-09 14:16:57 +03:00
|
|
|
|
2022-01-19 06:08:02 +03:00
|
|
|
if (buffer) {
|
|
|
|
*width = buffer->width;
|
|
|
|
*height = buffer->height;
|
|
|
|
} else {
|
2015-02-09 14:16:57 +03:00
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
/** Get the bounding box of a surface and its subsurfaces
|
|
|
|
*
|
|
|
|
* \param surface The surface to query.
|
|
|
|
* \return The bounding box relative to the surface origin.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_geometry
|
|
|
|
weston_surface_get_bounding_box(struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
pixman_region32_t region;
|
|
|
|
pixman_box32_t *box;
|
|
|
|
struct weston_subsurface *subsurface;
|
|
|
|
|
|
|
|
pixman_region32_init_rect(®ion,
|
|
|
|
0, 0,
|
|
|
|
surface->width, surface->height);
|
|
|
|
|
|
|
|
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link)
|
|
|
|
pixman_region32_union_rect(®ion, ®ion,
|
|
|
|
subsurface->position.x,
|
|
|
|
subsurface->position.y,
|
|
|
|
subsurface->surface->width,
|
|
|
|
subsurface->surface->height);
|
|
|
|
|
|
|
|
box = pixman_region32_extents(®ion);
|
|
|
|
struct weston_geometry geometry = {
|
|
|
|
.x = box->x1,
|
|
|
|
.y = box->y1,
|
|
|
|
.width = box->x2 - box->x1,
|
|
|
|
.height = box->y2 - box->y1,
|
|
|
|
};
|
|
|
|
|
|
|
|
pixman_region32_fini(®ion);
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2015-02-09 14:16:57 +03:00
|
|
|
/** Copy surface contents to system memory.
|
|
|
|
*
|
|
|
|
* \param surface The surface to copy from.
|
|
|
|
* \param target Pointer to the target memory buffer.
|
|
|
|
* \param size Size of the target buffer in bytes.
|
|
|
|
* \param src_x X location on contents to copy from.
|
|
|
|
* \param src_y Y location on contents to copy from.
|
|
|
|
* \param width Width in pixels of the area to copy.
|
|
|
|
* \param height Height in pixels of the area to copy.
|
|
|
|
* \return 0 for success, -1 for failure.
|
|
|
|
*
|
|
|
|
* Surface contents are maintained by the renderer. They can be in a
|
|
|
|
* reserved weston_buffer or as a copy, e.g. a GL texture, or something
|
|
|
|
* else.
|
|
|
|
*
|
|
|
|
* Surface contents are copied into memory pointed to by target,
|
|
|
|
* which has size bytes of space available. The target memory
|
|
|
|
* may be larger than needed, but being smaller returns an error.
|
|
|
|
* The extra bytes in target may or may not be written; their content is
|
|
|
|
* unspecified. Size must be large enough to hold the image.
|
|
|
|
*
|
|
|
|
* The image in the target memory will be arranged in rows from
|
|
|
|
* top to bottom, and pixels on a row from left to right. The pixel
|
|
|
|
* format is PIXMAN_a8b8g8r8, 4 bytes per pixel, and stride is exactly
|
|
|
|
* width * 4.
|
|
|
|
*
|
|
|
|
* Parameters src_x and src_y define the upper-left corner in buffer
|
|
|
|
* coordinates (pixels) to copy from. Parameters width and height
|
|
|
|
* define the size of the area to copy in pixels.
|
|
|
|
*
|
|
|
|
* The rectangle defined by src_x, src_y, width, height must fit in
|
|
|
|
* the surface contents. Otherwise an error is returned.
|
|
|
|
*
|
2017-08-04 18:30:47 +03:00
|
|
|
* Use weston_surface_get_content_size to determine the content size; the
|
2015-02-09 14:16:57 +03:00
|
|
|
* needed target buffer size and rectangle limits.
|
|
|
|
*
|
|
|
|
* CURRENT IMPLEMENTATION RESTRICTIONS:
|
|
|
|
* - the machine must be little-endian due to Pixman formats.
|
|
|
|
*
|
|
|
|
* NOTE: Pixman formats are premultiplied.
|
|
|
|
*/
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_surface_copy_content(struct weston_surface *surface,
|
|
|
|
void *target, size_t size,
|
|
|
|
int src_x, int src_y,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
struct weston_renderer *rer = surface->compositor->renderer;
|
|
|
|
int cw, ch;
|
|
|
|
const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
|
|
|
|
|
|
|
|
if (!rer->surface_copy_content)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
weston_surface_get_content_size(surface, &cw, &ch);
|
|
|
|
|
|
|
|
if (src_x < 0 || src_y < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (src_x + width > cw || src_y + height > ch)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (width * bytespp * height > size)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return rer->surface_copy_content(surface, target, size,
|
|
|
|
src_x, src_y, width, height);
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
static void
|
|
|
|
subsurface_set_position(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int32_t x, int32_t y)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
if (!sub)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sub->position.x = x;
|
|
|
|
sub->position.y = y;
|
|
|
|
sub->position.set = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct weston_subsurface *
|
2016-06-08 19:37:57 +03:00
|
|
|
subsurface_find_sibling(struct weston_subsurface *sub,
|
|
|
|
struct weston_surface *surface)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
{
|
2016-06-08 19:37:57 +03:00
|
|
|
struct weston_surface *parent = sub->parent;
|
|
|
|
struct weston_subsurface *sibling;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2016-06-08 19:37:57 +03:00
|
|
|
wl_list_for_each(sibling, &parent->subsurface_list, parent_link) {
|
|
|
|
if (sibling->surface == surface && sibling != sub)
|
|
|
|
return sibling;
|
|
|
|
}
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct weston_subsurface *
|
|
|
|
subsurface_sibling_check(struct weston_subsurface *sub,
|
|
|
|
struct weston_surface *surface,
|
|
|
|
const char *request)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sibling;
|
|
|
|
|
2016-06-08 19:37:57 +03:00
|
|
|
sibling = subsurface_find_sibling(sub, surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (!sibling) {
|
|
|
|
wl_resource_post_error(sub->resource,
|
|
|
|
WL_SUBSURFACE_ERROR_BAD_SURFACE,
|
|
|
|
"%s: wl_surface@%d is not a parent or sibling",
|
2013-06-07 07:34:41 +04:00
|
|
|
request, wl_resource_get_id(surface->resource));
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-08 19:37:57 +03:00
|
|
|
assert(sibling->parent == sub->parent);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
return sibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_place_above(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *sibling_resource)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(sibling_resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
struct weston_subsurface *sibling;
|
|
|
|
|
|
|
|
if (!sub)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sibling = subsurface_sibling_check(sub, surface, "place_above");
|
|
|
|
if (!sibling)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_remove(&sub->parent_link_pending);
|
|
|
|
wl_list_insert(sibling->parent_link_pending.prev,
|
|
|
|
&sub->parent_link_pending);
|
2017-01-27 19:30:29 +03:00
|
|
|
|
|
|
|
sub->reordered = true;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_place_below(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *sibling_resource)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(sibling_resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
struct weston_subsurface *sibling;
|
|
|
|
|
|
|
|
if (!sub)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sibling = subsurface_sibling_check(sub, surface, "place_below");
|
|
|
|
if (!sibling)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_remove(&sub->parent_link_pending);
|
|
|
|
wl_list_insert(&sibling->parent_link_pending,
|
|
|
|
&sub->parent_link_pending);
|
2017-01-27 19:30:29 +03:00
|
|
|
|
|
|
|
sub->reordered = true;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_set_sync(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
if (sub)
|
|
|
|
sub->synchronized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_set_desync(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2013-05-17 17:46:05 +04:00
|
|
|
if (sub && sub->synchronized) {
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
sub->synchronized = 0;
|
2013-05-17 17:46:05 +04:00
|
|
|
|
|
|
|
/* If sub became effectively desynchronized, flush. */
|
|
|
|
if (!weston_subsurface_is_synchronized(sub))
|
|
|
|
weston_subsurface_synchronized_commit(sub);
|
|
|
|
}
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_unlink_parent(struct weston_subsurface *sub)
|
|
|
|
{
|
|
|
|
wl_list_remove(&sub->parent_link);
|
|
|
|
wl_list_remove(&sub->parent_link_pending);
|
|
|
|
wl_list_remove(&sub->parent_destroy_listener.link);
|
|
|
|
sub->parent = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_destroy(struct weston_subsurface *sub);
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_handle_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub =
|
|
|
|
container_of(listener, struct weston_subsurface,
|
|
|
|
surface_destroy_listener);
|
2015-04-17 14:23:38 +03:00
|
|
|
assert(data == sub->surface);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
/* The protocol object (wl_resource) is left inert. */
|
|
|
|
if (sub->resource)
|
2013-06-14 19:08:02 +04:00
|
|
|
wl_resource_set_user_data(sub->resource, NULL);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
weston_subsurface_destroy(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_handle_parent_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub =
|
|
|
|
container_of(listener, struct weston_subsurface,
|
|
|
|
parent_destroy_listener);
|
2015-04-17 14:23:38 +03:00
|
|
|
assert(data == sub->parent);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
assert(sub->surface != sub->parent);
|
|
|
|
|
|
|
|
if (weston_surface_is_mapped(sub->surface))
|
|
|
|
weston_surface_unmap(sub->surface);
|
|
|
|
|
|
|
|
weston_subsurface_unlink_parent(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_resource_destroy(struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:08:02 +04:00
|
|
|
struct weston_subsurface *sub = wl_resource_get_user_data(resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
|
|
|
if (sub)
|
|
|
|
weston_subsurface_destroy(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subsurface_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_link_parent(struct weston_subsurface *sub,
|
|
|
|
struct weston_surface *parent)
|
|
|
|
{
|
|
|
|
sub->parent = parent;
|
|
|
|
sub->parent_destroy_listener.notify = subsurface_handle_parent_destroy;
|
2013-06-07 07:34:41 +04:00
|
|
|
wl_signal_add(&parent->destroy_signal,
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
&sub->parent_destroy_listener);
|
|
|
|
|
|
|
|
wl_list_insert(&parent->subsurface_list, &sub->parent_link);
|
|
|
|
wl_list_insert(&parent->subsurface_list_pending,
|
|
|
|
&sub->parent_link_pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_link_surface(struct weston_subsurface *sub,
|
|
|
|
struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
sub->surface = surface;
|
|
|
|
sub->surface_destroy_listener.notify =
|
|
|
|
subsurface_handle_surface_destroy;
|
2013-06-07 07:34:41 +04:00
|
|
|
wl_signal_add(&surface->destroy_signal,
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
&sub->surface_destroy_listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_subsurface_destroy(struct weston_subsurface *sub)
|
|
|
|
{
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view, *next;
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
assert(sub->surface);
|
|
|
|
|
|
|
|
if (sub->resource) {
|
|
|
|
assert(weston_surface_to_subsurface(sub->surface) == sub);
|
|
|
|
assert(sub->parent_destroy_listener.notify ==
|
|
|
|
subsurface_handle_parent_destroy);
|
|
|
|
|
2014-06-13 20:10:26 +04:00
|
|
|
wl_list_for_each_safe(view, next, &sub->surface->views, surface_link) {
|
|
|
|
weston_view_unmap(view);
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
weston_view_destroy(view);
|
2014-06-13 20:10:26 +04:00
|
|
|
}
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (sub->parent)
|
|
|
|
weston_subsurface_unlink_parent(sub);
|
|
|
|
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_fini(&sub->cached);
|
2022-01-15 06:12:53 +03:00
|
|
|
weston_buffer_reference(&sub->cached_buffer_ref, NULL,
|
|
|
|
BUFFER_WILL_NOT_BE_ACCESSED);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
sub->surface->committed = NULL;
|
|
|
|
sub->surface->committed_private = NULL;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
weston_surface_set_label_func(sub->surface, NULL);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
} else {
|
|
|
|
/* the dummy weston_subsurface for the parent itself */
|
|
|
|
assert(sub->parent_destroy_listener.notify == NULL);
|
|
|
|
wl_list_remove(&sub->parent_link);
|
|
|
|
wl_list_remove(&sub->parent_link_pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_remove(&sub->surface_destroy_listener.link);
|
|
|
|
free(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_subsurface_interface subsurface_implementation = {
|
|
|
|
subsurface_destroy,
|
|
|
|
subsurface_set_position,
|
|
|
|
subsurface_place_above,
|
|
|
|
subsurface_place_below,
|
|
|
|
subsurface_set_sync,
|
|
|
|
subsurface_set_desync
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct weston_subsurface *
|
|
|
|
weston_subsurface_create(uint32_t id, struct weston_surface *surface,
|
|
|
|
struct weston_surface *parent)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
2013-06-07 07:34:41 +04:00
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2014-11-21 09:21:57 +03:00
|
|
|
sub = zalloc(sizeof *sub);
|
|
|
|
if (sub == NULL)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return NULL;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_init(&sub->unused_views);
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
sub->resource =
|
|
|
|
wl_resource_create(client, &wl_subsurface_interface, 1, id);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
if (!sub->resource) {
|
|
|
|
free(sub);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(sub->resource,
|
|
|
|
&subsurface_implementation,
|
|
|
|
sub, subsurface_resource_destroy);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
weston_subsurface_link_surface(sub, surface);
|
|
|
|
weston_subsurface_link_parent(sub, parent);
|
2014-05-20 23:33:03 +04:00
|
|
|
weston_surface_state_init(&sub->cached);
|
|
|
|
sub->cached_buffer_ref.buffer = NULL;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
sub->synchronized = 1;
|
|
|
|
|
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a dummy subsurface for having the parent itself in its
|
|
|
|
* sub-surface lists. Makes stacking order manipulation easy.
|
|
|
|
*/
|
|
|
|
static struct weston_subsurface *
|
|
|
|
weston_subsurface_create_for_parent(struct weston_surface *parent)
|
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
|
2014-11-21 09:21:57 +03:00
|
|
|
sub = zalloc(sizeof *sub);
|
|
|
|
if (sub == NULL)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
weston_subsurface_link_surface(sub, parent);
|
|
|
|
sub->parent = parent;
|
|
|
|
wl_list_insert(&parent->subsurface_list, &sub->parent_link);
|
|
|
|
wl_list_insert(&parent->subsurface_list_pending,
|
|
|
|
&sub->parent_link_pending);
|
|
|
|
|
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subcompositor_get_subsurface(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *parent_resource)
|
|
|
|
{
|
2013-06-14 19:07:53 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
|
|
|
struct weston_surface *parent =
|
|
|
|
wl_resource_get_user_data(parent_resource);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
struct weston_subsurface *sub;
|
|
|
|
static const char where[] = "get_subsurface: wl_subsurface@";
|
|
|
|
|
|
|
|
if (surface == parent) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
|
|
|
|
"%s%d: wl_surface@%d cannot be its own parent",
|
2013-06-14 19:08:02 +04:00
|
|
|
where, id, wl_resource_get_id(surface_resource));
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_surface_to_subsurface(surface)) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
|
|
|
|
"%s%d: wl_surface@%d is already a sub-surface",
|
2013-06-14 19:08:02 +04:00
|
|
|
where, id, wl_resource_get_id(surface_resource));
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
compositor: send error for surface role resets
With the more accurate definition of wl_surface roles in Wayland,
enforce the restriction: a role is always set permanently, and
attempting to change it is a protocol error.
This patch is based on Jasper's patch:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016811.html
The difference in this patch compared to his are:
- send role errors on the interface whose request triggers it, not on
wl_surface
- an interface could have several requests assigning different roles,
cannot use wl_interface as the unique key; use an arbitary string
instead
- ensure in window-manager.c that create_shell_surface() ->
create_common_surface() is never called with surface->configure set,
to avoid compositor abort
- use wl_resource_post_no_memory() where appropriate instead of
hand-rolling it with wl_resource_post_error()
Ideally we would not add weston_surface::role_name field, but use
weston_surface::configure. At the moment this is not possible though,
because at least shell.c uses several different roles with the same
configure function. Drag'n'drop uses two configure functions for the
same role. The configure hook is also reset in several places,
which is not good for role tracking.
This patch overlooks the wl_surface roles assigned in privileged
extensions: screensaver, panel, background, lock, input panel.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-10-01 16:02:41 +04:00
|
|
|
if (weston_surface_set_role(surface, "wl_subsurface", resource,
|
|
|
|
WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE) < 0)
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
return;
|
|
|
|
|
2013-05-17 17:46:07 +04:00
|
|
|
if (weston_surface_get_main_surface(parent) == surface) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
|
|
|
|
"%s%d: wl_surface@%d is an ancestor of parent",
|
2013-06-14 19:08:02 +04:00
|
|
|
where, id, wl_resource_get_id(surface_resource));
|
2013-05-17 17:46:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
/* make sure the parent is in its own list */
|
|
|
|
if (wl_list_empty(&parent->subsurface_list)) {
|
|
|
|
if (!weston_subsurface_create_for_parent(parent)) {
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub = weston_subsurface_create(id, surface, parent);
|
|
|
|
if (!sub) {
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
surface->committed = subsurface_committed;
|
|
|
|
surface->committed_private = sub;
|
compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-06 20:36:51 +04:00
|
|
|
weston_surface_set_label_func(surface, subsurface_get_label);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
subcompositor_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_subcompositor_interface subcompositor_interface = {
|
|
|
|
subcompositor_destroy,
|
|
|
|
subcompositor_get_subsurface
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_subcompositor(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
2013-06-28 05:17:02 +04:00
|
|
|
struct wl_resource *resource;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
resource =
|
|
|
|
wl_resource_create(client, &wl_subcompositor_interface, 1, id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wl_resource_set_implementation(resource, &subcompositor_interface,
|
|
|
|
compositor, NULL);
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
}
|
|
|
|
|
2016-08-30 22:04:26 +03:00
|
|
|
/** Set a DPMS mode on all of the compositor's outputs
|
2015-12-12 00:11:38 +03:00
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
|
|
|
* \param state The DPMS state the outputs will be set to
|
|
|
|
*/
|
2012-02-29 21:53:50 +04:00
|
|
|
static void
|
2013-02-21 20:35:22 +04:00
|
|
|
weston_compositor_dpms(struct weston_compositor *compositor,
|
|
|
|
enum dpms_enum state)
|
2012-02-29 21:53:50 +04:00
|
|
|
{
|
2021-07-31 18:25:41 +03:00
|
|
|
struct weston_output *output;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
2021-07-31 18:25:41 +03:00
|
|
|
wl_list_for_each(output, &compositor->output_list, link)
|
2016-08-30 22:05:16 +03:00
|
|
|
if (output->set_dpms)
|
|
|
|
output->set_dpms(output, state);
|
2012-02-29 21:53:50 +04:00
|
|
|
}
|
|
|
|
|
2015-12-12 00:11:38 +03:00
|
|
|
/** Restores the compositor to active status
|
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
|
|
|
*
|
|
|
|
* If the compositor was in a sleeping mode, all outputs are powered
|
|
|
|
* back on via DPMS. Otherwise if the compositor was inactive
|
|
|
|
* (idle/locked, offscreen, or sleeping) then the compositor's wake
|
|
|
|
* signal will fire.
|
|
|
|
*
|
|
|
|
* Restarts the idle timer.
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2015-12-12 00:11:38 +03:00
|
|
|
*/
|
2011-11-15 15:34:49 +04:00
|
|
|
WL_EXPORT void
|
2013-02-21 20:35:22 +04:00
|
|
|
weston_compositor_wake(struct weston_compositor *compositor)
|
2011-11-15 15:34:49 +04:00
|
|
|
{
|
2013-09-30 16:14:47 +04:00
|
|
|
uint32_t old_state = compositor->state;
|
|
|
|
|
|
|
|
/* The state needs to be changed before emitting the wake
|
|
|
|
* signal because that may try to schedule a repaint which
|
|
|
|
* will not work if the compositor is still sleeping */
|
|
|
|
compositor->state = WESTON_COMPOSITOR_ACTIVE;
|
|
|
|
|
|
|
|
switch (old_state) {
|
2013-02-21 20:35:22 +04:00
|
|
|
case WESTON_COMPOSITOR_SLEEPING:
|
|
|
|
case WESTON_COMPOSITOR_IDLE:
|
2013-03-29 16:01:56 +04:00
|
|
|
case WESTON_COMPOSITOR_OFFSCREEN:
|
2016-11-08 18:47:09 +03:00
|
|
|
weston_compositor_dpms(compositor, WESTON_DPMS_ON);
|
2013-02-21 20:35:23 +04:00
|
|
|
wl_signal_emit(&compositor->wake_signal, compositor);
|
2013-02-21 20:35:22 +04:00
|
|
|
/* fall through */
|
|
|
|
default:
|
|
|
|
wl_event_source_timer_update(compositor->idle_source,
|
|
|
|
compositor->idle_time * 1000);
|
2011-11-15 15:34:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-12 00:11:38 +03:00
|
|
|
/** Turns off rendering and frame events for the compositor.
|
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
|
|
|
*
|
|
|
|
* This is used for example to prevent further rendering while the
|
|
|
|
* compositor is shutting down.
|
|
|
|
*
|
|
|
|
* Stops the idle timer.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2015-12-12 00:11:38 +03:00
|
|
|
*/
|
2013-03-29 16:01:56 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_offscreen(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
switch (compositor->state) {
|
|
|
|
case WESTON_COMPOSITOR_OFFSCREEN:
|
|
|
|
return;
|
|
|
|
case WESTON_COMPOSITOR_SLEEPING:
|
|
|
|
default:
|
|
|
|
compositor->state = WESTON_COMPOSITOR_OFFSCREEN;
|
|
|
|
wl_event_source_timer_update(compositor->idle_source, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-12 00:11:38 +03:00
|
|
|
/** Powers down all attached output devices
|
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
|
|
|
*
|
|
|
|
* Causes rendering to the outputs to cease, and no frame events to be
|
|
|
|
* sent. Only powers down the outputs if the compositor is not already
|
|
|
|
* in sleep mode.
|
|
|
|
*
|
|
|
|
* Stops the idle timer.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2015-12-12 00:11:38 +03:00
|
|
|
*/
|
2013-02-21 20:35:22 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_sleep(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
if (compositor->state == WESTON_COMPOSITOR_SLEEPING)
|
|
|
|
return;
|
|
|
|
|
2013-03-29 16:01:56 +04:00
|
|
|
wl_event_source_timer_update(compositor->idle_source, 0);
|
2013-02-21 20:35:22 +04:00
|
|
|
compositor->state = WESTON_COMPOSITOR_SLEEPING;
|
|
|
|
weston_compositor_dpms(compositor, WESTON_DPMS_OFF);
|
|
|
|
}
|
|
|
|
|
2015-12-12 00:11:38 +03:00
|
|
|
/** Sets compositor to idle mode
|
|
|
|
*
|
|
|
|
* \param data The compositor instance
|
|
|
|
*
|
|
|
|
* This is called when the idle timer fires. Once the compositor is in
|
|
|
|
* idle mode it requires a wake action (e.g. via
|
|
|
|
* weston_compositor_wake()) to restore it. The compositor's
|
|
|
|
* idle_signal will be triggered when the idle event occurs.
|
|
|
|
*
|
|
|
|
* Idleness can be inhibited by setting the compositor's idle_inhibit
|
|
|
|
* property.
|
|
|
|
*/
|
2011-04-22 22:01:18 +04:00
|
|
|
static int
|
|
|
|
idle_handler(void *data)
|
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor *compositor = data;
|
2011-04-22 22:01:18 +04:00
|
|
|
|
|
|
|
if (compositor->idle_inhibit)
|
|
|
|
return 1;
|
|
|
|
|
compositor: Move fade animation out of core Weston into shell
Previously, it was impossible to override the fade in/out behavior of
Weston using a different shell, since this was implemented in core
Weston. This also led to complicated interaction between the shell and
the core when displaying lock surfaces and screensavers.
This patch starts to solve this issue by moving the fade animation out
of the core. On compositor.c, besides deleting the fade code, the idle
handler had to be changed to emit the lock signal, since it was called
from the fade_frame() function before. This causes a slight change of
behavior, since before the fade would happen with the compositor being
active, while now it is already in the idle state. That leads to the
dpms state being set when cancelling the fade with mouse movement, and
in turn, to a slight freeze with drm compositor. This problem will be
fixed in a follow up patch.
On the shell side, the fade was re-implemented in a slightly different
manner. Instead of using a custom frame function, the fade animation
from animation.c is used. The interface for starting the fade was also
changed to take the value of an enum instead of a float alpha value,
in order to improve readability.
2013-02-21 20:35:20 +04:00
|
|
|
compositor->state = WESTON_COMPOSITOR_IDLE;
|
2013-02-21 20:35:23 +04:00
|
|
|
wl_signal_emit(&compositor->idle_signal, compositor);
|
2011-04-22 22:01:18 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
WL_EXPORT void
|
2013-10-23 09:58:31 +04:00
|
|
|
weston_plane_init(struct weston_plane *plane,
|
|
|
|
struct weston_compositor *ec,
|
|
|
|
int32_t x, int32_t y)
|
2012-08-03 19:30:18 +04:00
|
|
|
{
|
|
|
|
pixman_region32_init(&plane->damage);
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_init(&plane->clip);
|
2012-08-03 19:30:18 +04:00
|
|
|
plane->x = x;
|
|
|
|
plane->y = y;
|
2013-10-23 09:58:31 +04:00
|
|
|
plane->compositor = ec;
|
2013-07-05 17:05:26 +04:00
|
|
|
|
|
|
|
/* Init the link so that the call to wl_list_remove() when releasing
|
|
|
|
* the plane without ever stacking doesn't lead to a crash */
|
|
|
|
wl_list_init(&plane->link);
|
2012-08-03 19:30:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_plane_release(struct weston_plane *plane)
|
|
|
|
{
|
2013-10-23 09:58:31 +04:00
|
|
|
struct weston_view *view;
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
pixman_region32_fini(&plane->damage);
|
2013-03-05 19:30:29 +04:00
|
|
|
pixman_region32_fini(&plane->clip);
|
2013-07-05 17:05:26 +04:00
|
|
|
|
2021-05-03 16:09:45 +03:00
|
|
|
/*
|
|
|
|
* Can't use paint node list here, weston_plane is not specific to an
|
|
|
|
* output.
|
|
|
|
*/
|
2013-10-23 09:58:31 +04:00
|
|
|
wl_list_for_each(view, &plane->compositor->view_list, link) {
|
|
|
|
if (view->plane == plane)
|
|
|
|
view->plane = NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-05 17:05:26 +04:00
|
|
|
wl_list_remove(&plane->link);
|
2012-08-03 19:30:18 +04:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_stack_plane
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2013-03-05 19:30:27 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_stack_plane(struct weston_compositor *ec,
|
|
|
|
struct weston_plane *plane,
|
|
|
|
struct weston_plane *above)
|
|
|
|
{
|
|
|
|
if (above)
|
|
|
|
wl_list_insert(above->link.prev, &plane->link);
|
|
|
|
else
|
|
|
|
wl_list_insert(&ec->plane_list, &plane->link);
|
|
|
|
}
|
|
|
|
|
2016-07-05 21:44:33 +03:00
|
|
|
static void
|
|
|
|
output_release(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_output_interface output_interface = {
|
|
|
|
output_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-04-20 06:50:09 +04:00
|
|
|
static void unbind_resource(struct wl_resource *resource)
|
2011-10-12 06:20:37 +04:00
|
|
|
{
|
2013-06-14 19:08:01 +04:00
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
2011-10-12 06:20:37 +04:00
|
|
|
}
|
|
|
|
|
2009-01-01 00:18:42 +03:00
|
|
|
static void
|
2011-08-27 01:21:20 +04:00
|
|
|
bind_output(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
2009-01-01 00:18:42 +03:00
|
|
|
{
|
2017-03-27 12:24:34 +03:00
|
|
|
struct weston_head *head = data;
|
|
|
|
struct weston_output *output = head->output;
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_mode *mode;
|
2011-08-29 23:03:09 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
resource = wl_resource_create(client, &wl_output_interface,
|
2015-11-26 23:17:47 +03:00
|
|
|
version, id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
2009-01-01 00:18:42 +03:00
|
|
|
|
2017-03-27 12:15:38 +03:00
|
|
|
wl_list_insert(&head->resource_list, wl_resource_get_link(resource));
|
2017-03-27 16:31:25 +03:00
|
|
|
wl_resource_set_implementation(resource, &output_interface, head,
|
2017-03-27 12:24:34 +03:00
|
|
|
unbind_resource);
|
2012-04-20 06:50:09 +04:00
|
|
|
|
2017-03-27 12:24:34 +03:00
|
|
|
assert(output);
|
2012-03-05 06:57:37 +04:00
|
|
|
wl_output_send_geometry(resource,
|
|
|
|
output->x,
|
|
|
|
output->y,
|
2017-03-24 16:39:24 +03:00
|
|
|
head->mm_width,
|
|
|
|
head->mm_height,
|
|
|
|
head->subpixel,
|
|
|
|
head->make, head->model,
|
2012-08-10 18:09:20 +04:00
|
|
|
output->transform);
|
2014-08-08 00:43:11 +04:00
|
|
|
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
|
2013-05-22 16:41:37 +04:00
|
|
|
wl_output_send_scale(resource,
|
2013-09-19 01:56:35 +04:00
|
|
|
output->current_scale);
|
2011-06-21 19:16:58 +04:00
|
|
|
|
|
|
|
wl_list_for_each (mode, &output->mode_list, link) {
|
2012-03-05 06:57:37 +04:00
|
|
|
wl_output_send_mode(resource,
|
|
|
|
mode->flags,
|
|
|
|
mode->width,
|
|
|
|
mode->height,
|
|
|
|
mode->refresh);
|
2011-06-21 19:16:58 +04:00
|
|
|
}
|
2013-05-22 16:41:37 +04:00
|
|
|
|
2014-08-08 00:43:11 +04:00
|
|
|
if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
|
2013-05-22 16:41:37 +04:00
|
|
|
wl_output_send_done(resource);
|
2009-01-01 00:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-12-08 15:13:34 +03:00
|
|
|
static void
|
|
|
|
weston_head_add_global(struct weston_head *head)
|
|
|
|
{
|
|
|
|
head->global = wl_global_create(head->compositor->wl_display,
|
|
|
|
&wl_output_interface, 3,
|
|
|
|
head, bind_output);
|
|
|
|
}
|
|
|
|
|
2017-12-04 16:28:13 +03:00
|
|
|
/** Remove the global wl_output protocol object
|
|
|
|
*
|
|
|
|
* \param head The head whose global to remove.
|
|
|
|
*
|
|
|
|
* Also orphans the wl_resources for this head (wl_output).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_head_remove_global(struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource, *tmp;
|
|
|
|
|
|
|
|
if (head->global)
|
|
|
|
wl_global_destroy(head->global);
|
|
|
|
head->global = NULL;
|
|
|
|
|
|
|
|
wl_resource_for_each_safe(resource, tmp, &head->resource_list) {
|
|
|
|
unbind_resource(resource);
|
|
|
|
wl_resource_set_destructor(resource, NULL);
|
|
|
|
wl_resource_set_user_data(resource, NULL);
|
|
|
|
}
|
2019-03-29 15:01:06 +03:00
|
|
|
|
|
|
|
wl_resource_for_each(resource, &head->xdg_output_resource_list) {
|
|
|
|
/* It's sufficient to unset the destructor, then the list elements
|
|
|
|
* won't be accessed.
|
|
|
|
*/
|
|
|
|
wl_resource_set_destructor(resource, NULL);
|
|
|
|
}
|
|
|
|
wl_list_init(&head->xdg_output_resource_list);
|
2017-12-04 16:28:13 +03:00
|
|
|
}
|
|
|
|
|
2017-03-27 15:14:32 +03:00
|
|
|
/** Get the backing object of wl_output
|
|
|
|
*
|
|
|
|
* \param resource A wl_output protocol object.
|
|
|
|
* \return The backing object (user data) of a wl_resource representing a
|
|
|
|
* wl_output protocol object.
|
2019-06-11 00:05:08 +03:00
|
|
|
*
|
|
|
|
* \ingroup head
|
2017-03-27 15:14:32 +03:00
|
|
|
*/
|
2017-03-27 16:31:25 +03:00
|
|
|
WL_EXPORT struct weston_head *
|
|
|
|
weston_head_from_resource(struct wl_resource *resource)
|
2017-03-27 15:14:32 +03:00
|
|
|
{
|
|
|
|
assert(wl_resource_instance_of(resource, &wl_output_interface,
|
|
|
|
&output_interface));
|
|
|
|
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
}
|
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
/** Initialize a pre-allocated weston_head
|
|
|
|
*
|
|
|
|
* \param head The head to initialize.
|
2017-08-14 14:43:13 +03:00
|
|
|
* \param name The head name, e.g. the connector name or equivalent.
|
2017-03-28 16:27:25 +03:00
|
|
|
*
|
|
|
|
* The head will be safe to attach, detach and release.
|
|
|
|
*
|
2017-08-14 14:43:13 +03:00
|
|
|
* The name is used in logs, and can be used by compositors as a configuration
|
|
|
|
* identifier.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-28 16:27:25 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
2017-08-16 10:39:17 +03:00
|
|
|
WL_EXPORT void
|
2017-08-14 14:43:13 +03:00
|
|
|
weston_head_init(struct weston_head *head, const char *name)
|
2017-03-28 16:27:25 +03:00
|
|
|
{
|
|
|
|
/* Add some (in)sane defaults which can be used
|
|
|
|
* for checking if an output was properly configured
|
|
|
|
*/
|
|
|
|
memset(head, 0, sizeof *head);
|
|
|
|
|
2017-08-14 16:05:35 +03:00
|
|
|
wl_list_init(&head->compositor_link);
|
2017-10-10 11:21:58 +03:00
|
|
|
wl_signal_init(&head->destroy_signal);
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_init(&head->output_link);
|
|
|
|
wl_list_init(&head->resource_list);
|
2019-03-29 15:01:06 +03:00
|
|
|
wl_list_init(&head->xdg_output_resource_list);
|
2017-08-14 14:43:13 +03:00
|
|
|
head->name = strdup(name);
|
2021-07-08 14:47:54 +03:00
|
|
|
head->supported_eotf_mask = WESTON_EOTF_MODE_SDR;
|
2019-04-03 16:14:35 +03:00
|
|
|
head->current_protection = WESTON_HDCP_DISABLE;
|
2017-03-28 16:27:25 +03:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:29:40 +03:00
|
|
|
/** Send output heads changed signal
|
|
|
|
*
|
|
|
|
* \param output The output that changed.
|
|
|
|
*
|
|
|
|
* Notify that the enabled output gained and/or lost heads, or that the
|
|
|
|
* associated heads may have changed their connection status. This does not
|
|
|
|
* include cases where the output becomes enabled or disabled. The registered
|
|
|
|
* callbacks are called after the change has successfully happened.
|
|
|
|
*
|
|
|
|
* If connection status change causes the compositor to attach or detach a head
|
|
|
|
* to an enabled output, the registered callbacks may be called multiple times.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
|
|
|
* \ingroup output
|
2018-03-20 14:29:40 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_output_emit_heads_changed(struct weston_output *output)
|
|
|
|
{
|
|
|
|
wl_signal_emit(&output->compositor->output_heads_changed_signal,
|
|
|
|
output);
|
|
|
|
}
|
|
|
|
|
2017-08-15 13:00:02 +03:00
|
|
|
/** Idle task for emitting heads_changed_signal */
|
|
|
|
static void
|
|
|
|
weston_compositor_call_heads_changed(void *data)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
2018-03-20 14:29:40 +03:00
|
|
|
struct weston_head *head;
|
2017-08-15 13:00:02 +03:00
|
|
|
|
|
|
|
compositor->heads_changed_source = NULL;
|
|
|
|
|
|
|
|
wl_signal_emit(&compositor->heads_changed_signal, compositor);
|
2018-03-20 14:29:40 +03:00
|
|
|
|
|
|
|
wl_list_for_each(head, &compositor->head_list, compositor_link) {
|
|
|
|
if (head->output && head->output->enabled)
|
|
|
|
weston_output_emit_heads_changed(head->output);
|
|
|
|
}
|
2017-08-15 13:00:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Schedule a call on idle to heads_changed callback
|
|
|
|
*
|
|
|
|
* \param compositor The Compositor.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-08-15 13:00:02 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_compositor_schedule_heads_changed(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
|
|
|
|
if (compositor->heads_changed_source)
|
|
|
|
return;
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(compositor->wl_display);
|
|
|
|
compositor->heads_changed_source = wl_event_loop_add_idle(loop,
|
|
|
|
weston_compositor_call_heads_changed, compositor);
|
|
|
|
}
|
|
|
|
|
2017-08-14 16:05:35 +03:00
|
|
|
/** Register a new head
|
|
|
|
*
|
|
|
|
* \param compositor The compositor.
|
|
|
|
* \param head The head to register, must not be already registered.
|
|
|
|
*
|
2017-08-15 13:00:02 +03:00
|
|
|
* This signals the core that a new head has become available, leading to
|
|
|
|
* heads_changed hook being called later.
|
2017-08-14 16:05:35 +03:00
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-08-14 16:05:35 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
2017-08-16 10:39:17 +03:00
|
|
|
WL_EXPORT void
|
2017-08-14 16:05:35 +03:00
|
|
|
weston_compositor_add_head(struct weston_compositor *compositor,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
assert(wl_list_empty(&head->compositor_link));
|
|
|
|
assert(head->name);
|
|
|
|
|
|
|
|
wl_list_insert(compositor->head_list.prev, &head->compositor_link);
|
|
|
|
head->compositor = compositor;
|
2017-08-15 13:00:02 +03:00
|
|
|
weston_compositor_schedule_heads_changed(compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Adds a listener to be called when heads change
|
|
|
|
*
|
|
|
|
* \param compositor The compositor.
|
|
|
|
* \param listener The listener to add.
|
|
|
|
*
|
2019-06-12 16:05:44 +03:00
|
|
|
* The listener notify function argument is weston_compositor.
|
2017-08-15 13:00:02 +03:00
|
|
|
*
|
|
|
|
* The listener function will be called after heads are added or their
|
|
|
|
* connection status has changed. Several changes may be accumulated into a
|
|
|
|
* single call. The user is expected to iterate over the existing heads and
|
|
|
|
* check their statuses to find out what changed.
|
|
|
|
*
|
|
|
|
* \sa weston_compositor_iterate_heads, weston_head_is_connected,
|
|
|
|
* weston_head_is_enabled
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-08-15 13:00:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
|
|
|
|
struct wl_listener *listener)
|
|
|
|
{
|
|
|
|
wl_signal_add(&compositor->heads_changed_signal, listener);
|
2017-08-14 16:05:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Iterate over available heads
|
|
|
|
*
|
|
|
|
* \param compositor The compositor.
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param iter The iterator, or NULL for start.
|
2017-08-14 16:05:35 +03:00
|
|
|
* \return The next available head in the list.
|
|
|
|
*
|
|
|
|
* Returns all available heads, regardless of being connected or enabled.
|
|
|
|
*
|
|
|
|
* You can iterate over all heads as follows:
|
|
|
|
* \code
|
|
|
|
* struct weston_head *head = NULL;
|
|
|
|
*
|
|
|
|
* while ((head = weston_compositor_iterate_heads(compositor, head))) {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* If you cause \c iter to be removed from the list, you cannot use it to
|
|
|
|
* continue iterating. Removing any other item is safe.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-08-14 16:05:35 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_head *
|
|
|
|
weston_compositor_iterate_heads(struct weston_compositor *compositor,
|
|
|
|
struct weston_head *iter)
|
|
|
|
{
|
|
|
|
struct wl_list *list = &compositor->head_list;
|
|
|
|
struct wl_list *node;
|
|
|
|
|
|
|
|
assert(compositor);
|
|
|
|
assert(!iter || iter->compositor == compositor);
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
node = iter->compositor_link.next;
|
|
|
|
else
|
|
|
|
node = list->next;
|
|
|
|
|
|
|
|
assert(node);
|
|
|
|
assert(!iter || node != &iter->compositor_link);
|
|
|
|
|
|
|
|
if (node == list)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(node, struct weston_head, compositor_link);
|
|
|
|
}
|
|
|
|
|
2017-08-16 10:39:17 +03:00
|
|
|
/** Iterate over attached heads
|
|
|
|
*
|
|
|
|
* \param output The output whose heads to iterate.
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param iter The iterator, or NULL for start.
|
2017-08-16 10:39:17 +03:00
|
|
|
* \return The next attached head in the list.
|
|
|
|
*
|
|
|
|
* Returns all heads currently attached to the output.
|
|
|
|
*
|
|
|
|
* You can iterate over all heads as follows:
|
|
|
|
* \code
|
|
|
|
* struct weston_head *head = NULL;
|
|
|
|
*
|
|
|
|
* while ((head = weston_output_iterate_heads(output, head))) {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* If you cause \c iter to be removed from the list, you cannot use it to
|
|
|
|
* continue iterating. Removing any other item is safe.
|
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2017-08-16 10:39:17 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_head *
|
|
|
|
weston_output_iterate_heads(struct weston_output *output,
|
|
|
|
struct weston_head *iter)
|
|
|
|
{
|
|
|
|
struct wl_list *list = &output->head_list;
|
|
|
|
struct wl_list *node;
|
|
|
|
|
|
|
|
assert(output);
|
|
|
|
assert(!iter || iter->output == output);
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
node = iter->output_link.next;
|
|
|
|
else
|
|
|
|
node = list->next;
|
|
|
|
|
|
|
|
assert(node);
|
|
|
|
assert(!iter || node != &iter->output_link);
|
|
|
|
|
|
|
|
if (node == list)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(node, struct weston_head, output_link);
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:13:34 +03:00
|
|
|
/** Attach a head to an output
|
2017-03-28 16:27:25 +03:00
|
|
|
*
|
|
|
|
* \param output The output to attach to.
|
|
|
|
* \param head The head that is not yet attached.
|
|
|
|
* \return 0 on success, -1 on failure.
|
|
|
|
*
|
|
|
|
* Attaches the given head to the output. All heads of an output are clones
|
|
|
|
* and share the resolution and timings.
|
|
|
|
*
|
|
|
|
* Cloning heads this way uses less resources than creating an output for
|
|
|
|
* each head, but is not always possible due to environment, driver and hardware
|
|
|
|
* limitations.
|
|
|
|
*
|
|
|
|
* On failure, the head remains unattached. Success of this function does not
|
|
|
|
* guarantee the output configuration is actually valid. The final checks are
|
2017-12-08 15:13:34 +03:00
|
|
|
* made on weston_output_enable() unless the output was already enabled.
|
2017-03-28 16:27:25 +03:00
|
|
|
*
|
2019-06-11 01:15:35 +03:00
|
|
|
* \ingroup output
|
2017-03-28 16:27:25 +03:00
|
|
|
*/
|
2017-08-16 10:39:17 +03:00
|
|
|
WL_EXPORT int
|
2017-03-28 16:27:25 +03:00
|
|
|
weston_output_attach_head(struct weston_output *output,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
2017-12-08 15:13:34 +03:00
|
|
|
char *head_names;
|
2017-03-28 16:27:25 +03:00
|
|
|
|
|
|
|
if (!wl_list_empty(&head->output_link))
|
|
|
|
return -1;
|
|
|
|
|
2017-08-16 10:39:17 +03:00
|
|
|
if (output->attach_head) {
|
|
|
|
if (output->attach_head(output, head) < 0)
|
|
|
|
return -1;
|
|
|
|
} else if (!wl_list_empty(&output->head_list)) {
|
|
|
|
/* No support for clones in the legacy path. */
|
2017-03-28 16:27:25 +03:00
|
|
|
return -1;
|
2017-08-16 10:39:17 +03:00
|
|
|
}
|
2017-03-28 16:27:25 +03:00
|
|
|
|
|
|
|
head->output = output;
|
|
|
|
wl_list_insert(output->head_list.prev, &head->output_link);
|
|
|
|
|
2017-12-08 15:13:34 +03:00
|
|
|
if (output->enabled) {
|
|
|
|
weston_head_add_global(head);
|
|
|
|
|
|
|
|
head_names = weston_output_create_heads_string(output);
|
|
|
|
weston_log("Output '%s' updated to have head(s) %s\n",
|
|
|
|
output->name, head_names);
|
|
|
|
free(head_names);
|
2018-03-20 14:29:40 +03:00
|
|
|
|
|
|
|
weston_output_emit_heads_changed(output);
|
2017-12-08 15:13:34 +03:00
|
|
|
}
|
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Detach a head from its output
|
|
|
|
*
|
|
|
|
* \param head The head to detach.
|
|
|
|
*
|
|
|
|
* It is safe to detach a non-attached head.
|
|
|
|
*
|
2017-08-16 10:39:17 +03:00
|
|
|
* If the head is attached to an enabled output and the output will be left
|
|
|
|
* with no heads, the output will be disabled.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-16 10:39:17 +03:00
|
|
|
* \sa weston_output_disable
|
2017-03-28 16:27:25 +03:00
|
|
|
*/
|
2017-08-16 10:39:17 +03:00
|
|
|
WL_EXPORT void
|
2017-03-28 16:27:25 +03:00
|
|
|
weston_head_detach(struct weston_head *head)
|
|
|
|
{
|
2017-08-16 10:39:17 +03:00
|
|
|
struct weston_output *output = head->output;
|
2017-12-08 17:11:17 +03:00
|
|
|
char *head_names;
|
2017-08-16 10:39:17 +03:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_remove(&head->output_link);
|
|
|
|
wl_list_init(&head->output_link);
|
|
|
|
head->output = NULL;
|
2017-08-16 10:39:17 +03:00
|
|
|
|
|
|
|
if (!output)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (output->detach_head)
|
|
|
|
output->detach_head(output, head);
|
|
|
|
|
|
|
|
if (output->enabled) {
|
|
|
|
weston_head_remove_global(head);
|
|
|
|
|
2017-12-08 17:11:17 +03:00
|
|
|
if (wl_list_empty(&output->head_list)) {
|
|
|
|
weston_log("Output '%s' no heads left, disabling.\n",
|
|
|
|
output->name);
|
2017-08-16 10:39:17 +03:00
|
|
|
weston_output_disable(output);
|
2017-12-08 17:11:17 +03:00
|
|
|
} else {
|
|
|
|
head_names = weston_output_create_heads_string(output);
|
|
|
|
weston_log("Output '%s' updated to have head(s) %s\n",
|
|
|
|
output->name, head_names);
|
|
|
|
free(head_names);
|
2018-03-20 14:29:40 +03:00
|
|
|
|
|
|
|
weston_output_emit_heads_changed(output);
|
2017-12-08 17:11:17 +03:00
|
|
|
}
|
2017-08-16 10:39:17 +03:00
|
|
|
}
|
2017-03-28 16:27:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroy a head
|
|
|
|
*
|
|
|
|
* \param head The head to be released.
|
|
|
|
*
|
|
|
|
* Destroys the head. The caller is responsible for freeing the memory pointed
|
|
|
|
* to by \c head.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-28 16:27:25 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
2017-08-16 10:39:17 +03:00
|
|
|
WL_EXPORT void
|
2017-03-28 16:27:25 +03:00
|
|
|
weston_head_release(struct weston_head *head)
|
|
|
|
{
|
2021-12-09 15:07:21 +03:00
|
|
|
weston_signal_emit_mutable(&head->destroy_signal, head);
|
2017-10-10 11:21:58 +03:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
weston_head_detach(head);
|
2017-04-04 16:26:23 +03:00
|
|
|
|
|
|
|
free(head->make);
|
|
|
|
free(head->model);
|
|
|
|
free(head->serial_number);
|
2017-08-14 14:43:13 +03:00
|
|
|
free(head->name);
|
2017-08-14 16:05:35 +03:00
|
|
|
|
|
|
|
wl_list_remove(&head->compositor_link);
|
2017-03-28 16:27:25 +03:00
|
|
|
}
|
|
|
|
|
2017-08-28 14:11:02 +03:00
|
|
|
static void
|
|
|
|
weston_head_set_device_changed(struct weston_head *head)
|
|
|
|
{
|
|
|
|
head->device_changed = true;
|
|
|
|
|
|
|
|
if (head->compositor)
|
|
|
|
weston_compositor_schedule_heads_changed(head->compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** String equal comparison with NULLs being equal */
|
|
|
|
static bool
|
|
|
|
str_null_eq(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (!a && !b)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!!a != !!b)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return strcmp(a, b) == 0;
|
|
|
|
}
|
|
|
|
|
2017-03-24 16:39:24 +03:00
|
|
|
/** Store monitor make, model and serial number
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param make The monitor make. If EDID is available, the PNP ID. Otherwise
|
|
|
|
* any string, or NULL for none.
|
|
|
|
* \param model The monitor model or name, or a made-up string, or NULL for
|
|
|
|
* none.
|
|
|
|
* \param serialno The monitor serial number, a made-up string, or NULL for
|
|
|
|
* none.
|
|
|
|
*
|
2017-08-28 14:11:02 +03:00
|
|
|
* This may set the device_changed flag.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-24 16:39:24 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_monitor_strings(struct weston_head *head,
|
|
|
|
const char *make,
|
|
|
|
const char *model,
|
|
|
|
const char *serialno)
|
|
|
|
{
|
2017-08-28 14:11:02 +03:00
|
|
|
if (str_null_eq(head->make, make) &&
|
|
|
|
str_null_eq(head->model, model) &&
|
|
|
|
str_null_eq(head->serial_number, serialno))
|
|
|
|
return;
|
|
|
|
|
2017-04-04 16:26:23 +03:00
|
|
|
free(head->make);
|
|
|
|
free(head->model);
|
|
|
|
free(head->serial_number);
|
|
|
|
|
|
|
|
head->make = make ? strdup(make) : NULL;
|
|
|
|
head->model = model ? strdup(model) : NULL;
|
|
|
|
head->serial_number = serialno ? strdup(serialno) : NULL;
|
2017-08-28 14:11:02 +03:00
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
2017-03-24 16:39:24 +03:00
|
|
|
}
|
|
|
|
|
2018-08-30 18:38:03 +03:00
|
|
|
/** Store display non-desktop status
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param non_desktop Whether the head connects to a non-desktop display.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2018-08-30 18:38:03 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_non_desktop(struct weston_head *head, bool non_desktop)
|
|
|
|
{
|
|
|
|
if (head->non_desktop == non_desktop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
head->non_desktop = non_desktop;
|
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
|
|
|
}
|
|
|
|
|
2019-11-26 02:29:31 +03:00
|
|
|
/** Store display transformation
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param transform The transformation to apply for this head
|
|
|
|
*
|
|
|
|
* This may set the device_changed flag.
|
|
|
|
*
|
|
|
|
* \ingroup head
|
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_transform(struct weston_head *head, uint32_t transform)
|
|
|
|
{
|
|
|
|
if (head->transform == transform)
|
|
|
|
return;
|
|
|
|
|
|
|
|
head->transform = transform;
|
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-24 16:39:24 +03:00
|
|
|
/** Store physical image size
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param mm_width Image area width in millimeters.
|
|
|
|
* \param mm_height Image area height in millimeters.
|
|
|
|
*
|
2017-08-28 14:11:02 +03:00
|
|
|
* This may set the device_changed flag.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-24 16:39:24 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_physical_size(struct weston_head *head,
|
|
|
|
int32_t mm_width, int32_t mm_height)
|
|
|
|
{
|
2017-08-28 14:11:02 +03:00
|
|
|
if (head->mm_width == mm_width &&
|
|
|
|
head->mm_height == mm_height)
|
|
|
|
return;
|
|
|
|
|
2017-03-24 16:39:24 +03:00
|
|
|
head->mm_width = mm_width;
|
|
|
|
head->mm_height = mm_height;
|
2017-08-28 14:11:02 +03:00
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
2017-03-24 16:39:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Store monitor sub-pixel layout
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param sp Sub-pixel layout. The possible values are:
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_UNKNOWN,
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_NONE,
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB,
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR,
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_VERTICAL_RGB,
|
|
|
|
* - WL_OUTPUT_SUBPIXEL_VERTICAL_BGR
|
|
|
|
*
|
2017-08-28 14:11:02 +03:00
|
|
|
* This may set the device_changed flag.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-24 16:39:24 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_subpixel(struct weston_head *head,
|
|
|
|
enum wl_output_subpixel sp)
|
|
|
|
{
|
2017-08-28 14:11:02 +03:00
|
|
|
if (head->subpixel == sp)
|
|
|
|
return;
|
|
|
|
|
2017-03-24 16:39:24 +03:00
|
|
|
head->subpixel = sp;
|
2017-08-28 14:11:02 +03:00
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
2017-03-24 16:39:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Mark the monitor as internal
|
|
|
|
*
|
|
|
|
* This is used for embedded screens, like laptop panels.
|
|
|
|
*
|
|
|
|
* \param head The head to mark as internal.
|
|
|
|
*
|
|
|
|
* By default a head is external. The type is often inferred from the physical
|
|
|
|
* connector type.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-03-24 16:39:24 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_internal(struct weston_head *head)
|
|
|
|
{
|
|
|
|
head->connection_internal = true;
|
|
|
|
}
|
2017-03-27 15:14:32 +03:00
|
|
|
|
2017-08-14 15:45:14 +03:00
|
|
|
/** Store connector status
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param connected Whether the head is connected.
|
|
|
|
*
|
|
|
|
* Connectors are created as disconnected. This function can be used to
|
|
|
|
* set the connector status.
|
|
|
|
*
|
|
|
|
* The status should be set to true when a physical connector is connected to
|
|
|
|
* a video sink device like a monitor and to false when the connector is
|
|
|
|
* disconnected. For nested backends, the connection status should reflect the
|
|
|
|
* connection to the parent display server.
|
|
|
|
*
|
2017-08-15 13:00:02 +03:00
|
|
|
* When the connection status changes, it schedules a call to the heads_changed
|
2017-08-28 14:11:02 +03:00
|
|
|
* hook and sets the device_changed flag.
|
2017-08-15 13:00:02 +03:00
|
|
|
*
|
|
|
|
* \sa weston_compositor_set_heads_changed_cb
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-14 15:45:14 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_connection_status(struct weston_head *head, bool connected)
|
|
|
|
{
|
2017-08-15 13:00:02 +03:00
|
|
|
if (head->connected == connected)
|
|
|
|
return;
|
|
|
|
|
2017-08-14 15:45:14 +03:00
|
|
|
head->connected = connected;
|
2017-08-15 13:00:02 +03:00
|
|
|
|
2017-08-28 14:11:02 +03:00
|
|
|
weston_head_set_device_changed(head);
|
2017-08-14 15:45:14 +03:00
|
|
|
}
|
|
|
|
|
2021-07-08 14:47:54 +03:00
|
|
|
/** Store the set of supported EOTF modes
|
|
|
|
*
|
|
|
|
* \param head The head to modify.
|
|
|
|
* \param eotf_mask A bit mask with the possible bits or'ed together from
|
|
|
|
* enum weston_eotf_mode.
|
|
|
|
*
|
|
|
|
* This may set the device_changed flag.
|
|
|
|
*
|
|
|
|
* \ingroup head
|
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_supported_eotf_mask(struct weston_head *head,
|
|
|
|
uint32_t eotf_mask)
|
|
|
|
{
|
|
|
|
assert((eotf_mask & ~WESTON_EOTF_MODE_ALL_MASK) == 0);
|
|
|
|
|
|
|
|
if (head->supported_eotf_mask == eotf_mask)
|
|
|
|
return;
|
|
|
|
|
|
|
|
head->supported_eotf_mask = eotf_mask;
|
|
|
|
|
|
|
|
weston_head_set_device_changed(head);
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:14:35 +03:00
|
|
|
static void
|
|
|
|
weston_output_compute_protection(struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct weston_head *head;
|
|
|
|
enum weston_hdcp_protection op_protection;
|
|
|
|
bool op_protection_valid = false;
|
2019-04-03 16:51:58 +03:00
|
|
|
struct weston_compositor *wc = output->compositor;
|
2019-04-03 16:14:35 +03:00
|
|
|
|
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
if (!op_protection_valid) {
|
|
|
|
op_protection = head->current_protection;
|
|
|
|
op_protection_valid = true;
|
|
|
|
}
|
|
|
|
if (head->current_protection < op_protection)
|
|
|
|
op_protection = head->current_protection;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!op_protection_valid)
|
|
|
|
op_protection = WESTON_HDCP_DISABLE;
|
|
|
|
|
2019-04-03 16:51:58 +03:00
|
|
|
if (output->current_protection != op_protection) {
|
2019-04-03 16:14:35 +03:00
|
|
|
output->current_protection = op_protection;
|
2019-04-03 16:51:58 +03:00
|
|
|
weston_output_damage(output);
|
2019-07-08 10:53:24 +03:00
|
|
|
weston_schedule_surface_protection_update(wc);
|
2019-04-03 16:51:58 +03:00
|
|
|
}
|
2019-04-03 16:14:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_set_content_protection_status(struct weston_head *head,
|
|
|
|
enum weston_hdcp_protection status)
|
|
|
|
{
|
|
|
|
head->current_protection = status;
|
|
|
|
if (head->output)
|
|
|
|
weston_output_compute_protection(head->output);
|
|
|
|
}
|
|
|
|
|
2017-08-14 15:45:14 +03:00
|
|
|
/** Is the head currently connected?
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return Connection status.
|
|
|
|
*
|
|
|
|
* Returns true if the head is physically connected to a monitor, or in
|
|
|
|
* case of a nested backend returns true when there is a connection to the
|
|
|
|
* parent display server.
|
|
|
|
*
|
|
|
|
* This is independent from the head being enabled.
|
|
|
|
*
|
|
|
|
* \sa weston_head_is_enabled
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-14 15:45:14 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_head_is_connected(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->connected;
|
|
|
|
}
|
|
|
|
|
2018-02-15 16:18:20 +03:00
|
|
|
/** Is the head currently enabled?
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return Video status.
|
|
|
|
*
|
|
|
|
* Returns true if the head is currently transmitting a video stream.
|
|
|
|
*
|
|
|
|
* This is independent of the head being connected.
|
|
|
|
*
|
|
|
|
* \sa weston_head_is_connected
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2018-02-15 16:18:20 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_head_is_enabled(struct weston_head *head)
|
|
|
|
{
|
|
|
|
if (!head->output)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return head->output->enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-28 14:11:02 +03:00
|
|
|
/** Has the device information changed?
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return True if the device information has changed since last reset.
|
|
|
|
*
|
|
|
|
* The information about the connected display device, e.g. a monitor, may
|
|
|
|
* change without being disconnected in between. Changing information
|
|
|
|
* causes a call to the heads_changed hook.
|
|
|
|
*
|
|
|
|
* The information includes make, model, serial number, physical size,
|
|
|
|
* and sub-pixel type. The connection status is also included.
|
|
|
|
*
|
|
|
|
* \sa weston_head_reset_device_changed, weston_compositor_set_heads_changed_cb
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-28 14:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_head_is_device_changed(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->device_changed;
|
|
|
|
}
|
|
|
|
|
2018-08-30 18:38:03 +03:00
|
|
|
/** Does the head represent a non-desktop display?
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return True if the device is a non-desktop display.
|
|
|
|
*
|
|
|
|
* Non-desktop heads are not attached to outputs by default.
|
|
|
|
* This stops weston from extending the desktop onto head mounted displays.
|
|
|
|
*
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2018-08-30 18:38:03 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_head_is_non_desktop(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->non_desktop;
|
|
|
|
}
|
|
|
|
|
2017-08-28 14:11:02 +03:00
|
|
|
/** Acknowledge device information change
|
|
|
|
*
|
|
|
|
* \param head The head to acknowledge.
|
|
|
|
*
|
|
|
|
* Clears the device changed flag on this head. When a compositor has processed
|
|
|
|
* device information, it should call this to be able to notice further
|
|
|
|
* changes.
|
|
|
|
*
|
|
|
|
* \sa weston_head_is_device_changed
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-28 14:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_reset_device_changed(struct weston_head *head)
|
|
|
|
{
|
|
|
|
head->device_changed = false;
|
|
|
|
}
|
|
|
|
|
2017-08-16 10:39:17 +03:00
|
|
|
/** Get the name of a head
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return The head's name, not NULL.
|
|
|
|
*
|
|
|
|
* The name depends on the backend. The DRM backend uses connector names,
|
|
|
|
* other backends may use hardcoded names or user-given names.
|
2019-06-11 00:05:08 +03:00
|
|
|
*
|
|
|
|
* \ingroup head
|
2017-08-16 10:39:17 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT const char *
|
|
|
|
weston_head_get_name(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the output the head is attached to
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return The output the head is attached to, or NULL if detached.
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-08-16 10:39:17 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_output *
|
|
|
|
weston_head_get_output(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->output;
|
|
|
|
}
|
|
|
|
|
2019-11-26 02:29:31 +03:00
|
|
|
/** Get the head's native transformation
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \return The head's native transform, as a WL_OUTPUT_TRANSFORM_* value
|
|
|
|
*
|
|
|
|
* A weston_head may have a 'native' transform provided by the backend.
|
|
|
|
* Examples include panels which are physically rotated, where the rotation
|
|
|
|
* is recorded and described as part of the system configuration. This call
|
|
|
|
* will return any known native transform for the head.
|
|
|
|
*
|
|
|
|
* \ingroup head
|
|
|
|
*/
|
|
|
|
WL_EXPORT uint32_t
|
|
|
|
weston_head_get_transform(struct weston_head *head)
|
|
|
|
{
|
|
|
|
return head->transform;
|
|
|
|
}
|
|
|
|
|
2017-10-10 11:21:58 +03:00
|
|
|
/** Add destroy callback for a head
|
|
|
|
*
|
|
|
|
* \param head The head to watch for.
|
|
|
|
* \param listener The listener to add. The \c notify member must be set.
|
|
|
|
*
|
|
|
|
* Heads may get destroyed for various reasons by the backends. If a head is
|
|
|
|
* attached to an output, the compositor should listen for head destruction
|
|
|
|
* and reconfigure or destroy the output if necessary.
|
|
|
|
*
|
|
|
|
* The destroy callbacks will be called on weston_head destruction before any
|
|
|
|
* automatic detaching from an associated weston_output and before any
|
|
|
|
* weston_head information is lost.
|
|
|
|
*
|
|
|
|
* The \c data argument to the notify callback is the weston_head being
|
|
|
|
* destroyed.
|
2019-06-11 00:05:08 +03:00
|
|
|
*
|
|
|
|
* \ingroup head
|
2017-10-10 11:21:58 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_head_add_destroy_listener(struct weston_head *head,
|
|
|
|
struct wl_listener *listener)
|
|
|
|
{
|
|
|
|
wl_signal_add(&head->destroy_signal, listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Look up destroy listener for a head
|
|
|
|
*
|
|
|
|
* \param head The head to query.
|
|
|
|
* \param notify The notify function used used for the added destroy listener.
|
|
|
|
* \return The listener, or NULL if not found.
|
|
|
|
*
|
|
|
|
* This looks up the previously added destroy listener struct based on the
|
|
|
|
* notify function it has. The listener can be used to access user data
|
|
|
|
* through \c container_of().
|
|
|
|
*
|
|
|
|
* \sa wl_signal_get()
|
2019-06-11 00:05:08 +03:00
|
|
|
* \ingroup head
|
2017-10-10 11:21:58 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct wl_listener *
|
|
|
|
weston_head_get_destroy_listener(struct weston_head *head,
|
|
|
|
wl_notify_func_t notify)
|
|
|
|
{
|
|
|
|
return wl_signal_get(&head->destroy_signal, notify);
|
|
|
|
}
|
|
|
|
|
2016-05-28 00:22:57 +03:00
|
|
|
/* Move other outputs when one is resized so the space remains contiguous. */
|
2013-12-14 00:10:51 +04:00
|
|
|
static void
|
2016-05-28 00:22:57 +03:00
|
|
|
weston_compositor_reflow_outputs(struct weston_compositor *compositor,
|
|
|
|
struct weston_output *resized_output, int delta_width)
|
2013-12-14 00:10:51 +04:00
|
|
|
{
|
|
|
|
struct weston_output *output;
|
2016-05-28 00:22:57 +03:00
|
|
|
bool start_resizing = false;
|
|
|
|
|
|
|
|
if (!delta_width)
|
|
|
|
return;
|
2013-12-14 00:10:51 +04:00
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
2016-05-28 00:22:57 +03:00
|
|
|
if (output == resized_output) {
|
|
|
|
start_resizing = true;
|
2013-12-14 00:10:51 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-05-28 00:22:57 +03:00
|
|
|
if (start_resizing) {
|
|
|
|
weston_output_move(output, output->x + delta_width, output->y);
|
2013-12-14 00:10:51 +04:00
|
|
|
output->dirty = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 16:22:36 +03:00
|
|
|
/** Transform a region in-place from global to output coordinates
|
|
|
|
*
|
|
|
|
* \param output The output that defines the transformation.
|
|
|
|
* \param region The region to be transformed in-place.
|
|
|
|
*
|
|
|
|
* This takes a region in the global coordinate system, and takes into account
|
2022-01-26 18:33:30 +03:00
|
|
|
* output position, transform and scale, and converts the region into output
|
|
|
|
* pixel coordinates in the framebuffer.
|
2020-12-08 16:22:36 +03:00
|
|
|
*
|
|
|
|
* \internal
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_region_from_global(struct weston_output *output,
|
|
|
|
pixman_region32_t *region)
|
|
|
|
{
|
2022-01-26 18:33:30 +03:00
|
|
|
pixman_region32_translate(region, -output->x, -output->y);
|
|
|
|
weston_transformed_region(output->width, output->height,
|
|
|
|
output->transform,
|
|
|
|
output->current_scale,
|
|
|
|
region, region);
|
2020-12-08 16:22:36 +03:00
|
|
|
}
|
|
|
|
|
2017-03-29 17:01:41 +03:00
|
|
|
static void
|
2012-02-23 01:21:41 +04:00
|
|
|
weston_output_update_matrix(struct weston_output *output)
|
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_matrix_init(&output->matrix);
|
2014-10-16 19:55:21 +04:00
|
|
|
weston_matrix_translate(&output->matrix, -output->x, -output->y, 0);
|
2012-08-18 11:04:05 +04:00
|
|
|
|
2014-10-16 19:55:21 +04:00
|
|
|
switch (output->transform) {
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
|
|
|
weston_matrix_translate(&output->matrix, -output->width, 0, 0);
|
|
|
|
weston_matrix_scale(&output->matrix, -1, 1, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (output->transform) {
|
|
|
|
default:
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
weston_matrix_translate(&output->matrix, -output->width, 0, 0);
|
|
|
|
weston_matrix_rotate_xy(&output->matrix, 0, -1);
|
2014-10-16 19:55:21 +04:00
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
weston_matrix_translate(&output->matrix,
|
|
|
|
-output->width, -output->height, 0);
|
|
|
|
weston_matrix_rotate_xy(&output->matrix, -1, 0);
|
|
|
|
break;
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
weston_matrix_translate(&output->matrix, 0, -output->height, 0);
|
|
|
|
weston_matrix_rotate_xy(&output->matrix, 0, 1);
|
2014-10-16 19:55:21 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output->current_scale != 1)
|
|
|
|
weston_matrix_scale(&output->matrix,
|
|
|
|
output->current_scale,
|
|
|
|
output->current_scale, 1);
|
2014-05-06 22:04:15 +04:00
|
|
|
|
2012-02-23 01:21:41 +04:00
|
|
|
output->dirty = 0;
|
2015-03-24 19:36:13 +03:00
|
|
|
|
|
|
|
weston_matrix_invert(&output->inverse_matrix, &output->matrix);
|
2012-02-23 01:21:41 +04:00
|
|
|
}
|
|
|
|
|
2012-08-18 11:04:05 +04:00
|
|
|
static void
|
2013-05-28 18:23:36 +04:00
|
|
|
weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
|
2012-08-18 11:04:05 +04:00
|
|
|
{
|
|
|
|
output->transform = transform;
|
2016-04-26 15:50:59 +03:00
|
|
|
output->native_scale = scale;
|
|
|
|
output->current_scale = scale;
|
2012-08-18 11:04:05 +04:00
|
|
|
|
2016-04-26 15:50:59 +03:00
|
|
|
convert_size_by_transform_scale(&output->width, &output->height,
|
|
|
|
output->current_mode->width,
|
|
|
|
output->current_mode->height,
|
|
|
|
transform, scale);
|
2013-05-22 16:41:37 +04:00
|
|
|
}
|
|
|
|
|
2013-12-14 00:10:53 +04:00
|
|
|
static void
|
|
|
|
weston_output_init_geometry(struct weston_output *output, int x, int y)
|
2012-02-23 01:21:41 +04:00
|
|
|
{
|
|
|
|
output->x = x;
|
|
|
|
output->y = y;
|
|
|
|
|
2017-03-30 16:04:58 +03:00
|
|
|
pixman_region32_fini(&output->region);
|
2012-02-23 01:21:41 +04:00
|
|
|
pixman_region32_init_rect(&output->region, x, y,
|
2012-08-18 11:04:05 +04:00
|
|
|
output->width,
|
|
|
|
output->height);
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 01:15:35 +03:00
|
|
|
/**
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
2013-12-14 00:10:53 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_move(struct weston_output *output, int x, int y)
|
|
|
|
{
|
2017-03-28 16:27:25 +03:00
|
|
|
struct weston_head *head;
|
2013-12-14 00:10:53 +04:00
|
|
|
struct wl_resource *resource;
|
2017-03-28 16:27:25 +03:00
|
|
|
int ver;
|
2013-12-14 00:10:53 +04:00
|
|
|
|
|
|
|
output->move_x = x - output->x;
|
|
|
|
output->move_y = y - output->y;
|
|
|
|
|
|
|
|
if (output->move_x == 0 && output->move_y == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_output_init_geometry(output, x, y);
|
|
|
|
|
|
|
|
output->dirty = 1;
|
|
|
|
|
|
|
|
/* Move views on this output. */
|
2014-01-29 20:47:52 +04:00
|
|
|
wl_signal_emit(&output->compositor->output_moved_signal, output);
|
2013-12-14 00:10:53 +04:00
|
|
|
|
|
|
|
/* Notify clients of the change for output position. */
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
wl_resource_for_each(resource, &head->resource_list) {
|
|
|
|
wl_output_send_geometry(resource,
|
|
|
|
output->x,
|
|
|
|
output->y,
|
|
|
|
head->mm_width,
|
|
|
|
head->mm_height,
|
|
|
|
head->subpixel,
|
|
|
|
head->make,
|
|
|
|
head->model,
|
|
|
|
output->transform);
|
|
|
|
|
|
|
|
ver = wl_resource_get_version(resource);
|
|
|
|
if (ver >= WL_OUTPUT_DONE_SINCE_VERSION)
|
|
|
|
wl_output_send_done(resource);
|
|
|
|
}
|
2019-03-29 15:01:06 +03:00
|
|
|
|
|
|
|
wl_resource_for_each(resource, &head->xdg_output_resource_list) {
|
|
|
|
zxdg_output_v1_send_logical_position(resource,
|
|
|
|
output->x,
|
|
|
|
output->y);
|
|
|
|
zxdg_output_v1_send_done(resource);
|
|
|
|
}
|
2014-03-14 05:16:25 +04:00
|
|
|
}
|
2013-12-14 00:10:53 +04:00
|
|
|
}
|
|
|
|
|
2017-03-29 16:20:19 +03:00
|
|
|
/** Signal that a pending output is taken into use.
|
|
|
|
*
|
|
|
|
* Removes the output from the pending list and adds it to the compositor's
|
|
|
|
* list of enabled outputs. The output created signal is emitted.
|
2015-05-06 21:41:57 +03:00
|
|
|
*
|
2017-03-30 15:48:06 +03:00
|
|
|
* The output gets an internal ID assigned, and the wl_output global is
|
|
|
|
* created.
|
2017-03-30 15:19:45 +03:00
|
|
|
*
|
2015-05-06 21:41:57 +03:00
|
|
|
* \param compositor The compositor instance.
|
|
|
|
* \param output The output to be added.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
|
|
|
* \internal
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2015-05-06 21:41:57 +03:00
|
|
|
*/
|
2017-03-29 16:58:48 +03:00
|
|
|
static void
|
2015-05-06 21:41:57 +03:00
|
|
|
weston_compositor_add_output(struct weston_compositor *compositor,
|
|
|
|
struct weston_output *output)
|
|
|
|
{
|
2016-08-05 16:28:29 +03:00
|
|
|
struct weston_view *view, *next;
|
2017-03-27 12:15:38 +03:00
|
|
|
struct weston_head *head;
|
2016-08-05 16:28:29 +03:00
|
|
|
|
2017-03-30 14:56:22 +03:00
|
|
|
assert(!output->enabled);
|
2017-03-30 15:19:45 +03:00
|
|
|
|
|
|
|
/* Verify we haven't reached the limit of 32 available output IDs */
|
|
|
|
assert(ffs(~compositor->output_id_pool) > 0);
|
|
|
|
|
|
|
|
/* Invert the output id pool and look for the lowest numbered
|
|
|
|
* switch (the least significant bit). Take that bit's position
|
|
|
|
* as our ID, and mark it used in the compositor's output_id_pool.
|
|
|
|
*/
|
|
|
|
output->id = ffs(~compositor->output_id_pool) - 1;
|
|
|
|
compositor->output_id_pool |= 1u << output->id;
|
|
|
|
|
2017-03-29 16:20:19 +03:00
|
|
|
wl_list_remove(&output->link);
|
2015-05-06 21:41:57 +03:00
|
|
|
wl_list_insert(compositor->output_list.prev, &output->link);
|
2017-03-30 14:56:22 +03:00
|
|
|
output->enabled = true;
|
2017-03-29 16:20:19 +03:00
|
|
|
|
2017-12-08 15:13:34 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link)
|
|
|
|
weston_head_add_global(head);
|
2017-03-30 15:48:06 +03:00
|
|
|
|
2015-05-06 21:41:57 +03:00
|
|
|
wl_signal_emit(&compositor->output_created_signal, output);
|
2016-08-05 16:28:29 +03:00
|
|
|
|
2021-05-03 16:09:45 +03:00
|
|
|
/*
|
|
|
|
* Use view_list, as paint nodes have not been created for this
|
|
|
|
* output yet. Any existing view might touch this new output.
|
|
|
|
*/
|
2016-08-05 16:28:29 +03:00
|
|
|
wl_list_for_each_safe(view, next, &compositor->view_list, link)
|
|
|
|
weston_view_geometry_dirty(view);
|
2010-06-14 19:54:00 +04:00
|
|
|
}
|
|
|
|
|
2017-03-29 16:53:50 +03:00
|
|
|
/** Transform device coordinates into global coordinates
|
|
|
|
*
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param output the weston_output object
|
|
|
|
* \param[in] device_x X coordinate in device units.
|
|
|
|
* \param[in] device_y Y coordinate in device units.
|
|
|
|
* \param[out] x X coordinate in the global space.
|
|
|
|
* \param[out] y Y coordinate in the global space.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2019-06-12 16:05:44 +03:00
|
|
|
* Transforms coordinates from the device coordinate space (physical pixel
|
|
|
|
* units) to the global coordinate space (logical pixel units). This takes
|
|
|
|
* into account output transform and scale.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2019-06-11 01:15:35 +03:00
|
|
|
* \ingroup output
|
2017-03-29 16:53:50 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
2013-07-23 01:33:42 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_transform_coordinate(struct weston_output *output,
|
2016-03-22 18:44:54 +03:00
|
|
|
double device_x, double device_y,
|
|
|
|
double *x, double *y)
|
2013-07-23 01:33:42 +04:00
|
|
|
{
|
2014-10-02 22:41:17 +04:00
|
|
|
struct weston_vector p = { {
|
2016-03-22 18:44:54 +03:00
|
|
|
device_x,
|
|
|
|
device_y,
|
2014-10-02 22:41:17 +04:00
|
|
|
0.0,
|
|
|
|
1.0 } };
|
2013-07-23 01:33:42 +04:00
|
|
|
|
2015-03-24 19:36:14 +03:00
|
|
|
weston_matrix_transform(&output->inverse_matrix, &p);
|
2013-07-23 01:33:42 +04:00
|
|
|
|
2016-03-22 18:44:54 +03:00
|
|
|
*x = p.f[0] / p.f[3];
|
|
|
|
*y = p.f[1] / p.f[3];
|
2013-07-23 01:33:42 +04:00
|
|
|
}
|
|
|
|
|
2022-04-28 15:25:00 +03:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_color_outcome_destroy(struct weston_output_color_outcome **pco)
|
2021-02-25 13:03:28 +03:00
|
|
|
{
|
2022-04-28 15:25:00 +03:00
|
|
|
struct weston_output_color_outcome *co = *pco;
|
|
|
|
|
|
|
|
if (!co)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_color_transform_unref(co->from_sRGB_to_output);
|
|
|
|
weston_color_transform_unref(co->from_sRGB_to_blend);
|
|
|
|
weston_color_transform_unref(co->from_blend_to_output);
|
|
|
|
|
2022-04-29 11:20:34 +03:00
|
|
|
free(co);
|
2022-04-28 15:25:00 +03:00
|
|
|
*pco = NULL;
|
2021-02-25 13:03:28 +03:00
|
|
|
}
|
|
|
|
|
2021-06-08 13:38:35 +03:00
|
|
|
static bool
|
2022-04-29 11:20:34 +03:00
|
|
|
weston_output_set_color_outcome(struct weston_output *output)
|
2021-06-08 13:38:35 +03:00
|
|
|
{
|
|
|
|
struct weston_color_manager *cm = output->compositor->color_manager;
|
2022-04-29 11:20:34 +03:00
|
|
|
struct weston_output_color_outcome *colorout;
|
|
|
|
|
|
|
|
colorout = cm->create_output_color_outcome(cm, output);
|
|
|
|
if (!colorout) {
|
2021-06-08 13:38:35 +03:00
|
|
|
weston_log("Creating color transformation for output \"%s\" failed.\n",
|
|
|
|
output->name);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-28 15:25:00 +03:00
|
|
|
weston_output_color_outcome_destroy(&output->color_outcome);
|
2022-04-29 11:20:34 +03:00
|
|
|
output->color_outcome = colorout;
|
2022-04-28 15:25:00 +03:00
|
|
|
|
2021-06-08 13:38:35 +03:00
|
|
|
output->from_blend_to_output_by_backend = false;
|
|
|
|
|
2021-06-08 14:17:44 +03:00
|
|
|
weston_log("Output '%s' using color profile: %s\n", output->name,
|
|
|
|
weston_color_profile_get_description(output->color_profile));
|
|
|
|
|
2021-06-08 13:38:35 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-29 16:07:34 +03:00
|
|
|
/** Removes output from compositor's list of enabled outputs
|
2016-09-30 15:11:02 +03:00
|
|
|
*
|
|
|
|
* \param output The weston_output object that is being removed.
|
|
|
|
*
|
2017-03-29 16:07:34 +03:00
|
|
|
* The following happens:
|
|
|
|
*
|
2021-04-30 14:48:52 +03:00
|
|
|
* - Destroys all paint nodes related to the output.
|
|
|
|
*
|
2017-03-29 16:07:34 +03:00
|
|
|
* - The output assignments of all views in the current scenegraph are
|
|
|
|
* recomputed.
|
|
|
|
*
|
2021-02-25 13:03:28 +03:00
|
|
|
* - Destroys output's color transforms.
|
|
|
|
*
|
2017-03-29 16:07:34 +03:00
|
|
|
* - Presentation feedback is discarded.
|
|
|
|
*
|
|
|
|
* - Compositor is notified that outputs were changed and
|
|
|
|
* applies the necessary changes to re-layout outputs.
|
|
|
|
*
|
2017-03-29 16:20:19 +03:00
|
|
|
* - The output is put back in the pending outputs list.
|
|
|
|
*
|
2017-03-29 16:07:34 +03:00
|
|
|
* - Signal is emitted to notify all users of the weston_output
|
|
|
|
* object that the output is being destroyed.
|
|
|
|
*
|
|
|
|
* - wl_output protocol objects referencing this weston_output
|
2017-03-30 15:48:06 +03:00
|
|
|
* are made inert, and the wl_output global is removed.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2017-03-30 15:19:45 +03:00
|
|
|
* - The output's internal ID is released.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-03-29 16:53:50 +03:00
|
|
|
* \internal
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_compositor_remove_output(struct weston_output *output)
|
|
|
|
{
|
2017-03-29 16:16:04 +03:00
|
|
|
struct weston_compositor *compositor = output->compositor;
|
2021-04-30 14:48:52 +03:00
|
|
|
struct weston_paint_node *pnode, *pntmp;
|
2016-09-30 15:11:02 +03:00
|
|
|
struct weston_view *view;
|
2017-03-27 12:15:38 +03:00
|
|
|
struct weston_head *head;
|
2016-09-30 15:11:02 +03:00
|
|
|
|
|
|
|
assert(output->destroying);
|
2017-03-30 14:56:22 +03:00
|
|
|
assert(output->enabled);
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_for_each_safe(pnode, pntmp,
|
|
|
|
&output->paint_node_list, output_link) {
|
|
|
|
weston_paint_node_destroy(pnode);
|
|
|
|
}
|
2021-04-30 17:41:29 +03:00
|
|
|
assert(wl_list_empty(&output->paint_node_z_order_list));
|
2021-04-30 14:48:52 +03:00
|
|
|
|
2021-05-03 16:09:45 +03:00
|
|
|
/*
|
|
|
|
* Use view_list in case the output did not go through repaint
|
|
|
|
* after a view came on it, lacking a paint node. Just to be sure.
|
|
|
|
*/
|
2017-03-29 16:16:04 +03:00
|
|
|
wl_list_for_each(view, &compositor->view_list, link) {
|
2016-09-30 15:11:02 +03:00
|
|
|
if (view->output_mask & (1u << output->id))
|
|
|
|
weston_view_assign_output(view);
|
|
|
|
}
|
|
|
|
|
2022-04-28 15:25:00 +03:00
|
|
|
weston_output_color_outcome_destroy(&output->color_outcome);
|
2021-02-25 13:03:28 +03:00
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
weston_presentation_feedback_discard_list(&output->feedback_list);
|
|
|
|
|
2018-06-21 14:26:18 +03:00
|
|
|
weston_compositor_reflow_outputs(compositor, output, -output->width);
|
2017-03-29 16:20:19 +03:00
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
wl_list_remove(&output->link);
|
2017-03-29 16:20:19 +03:00
|
|
|
wl_list_insert(compositor->pending_output_list.prev, &output->link);
|
2017-03-30 14:56:22 +03:00
|
|
|
output->enabled = false;
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2021-12-02 12:15:15 +03:00
|
|
|
weston_signal_emit_mutable(&compositor->output_destroyed_signal, output);
|
|
|
|
weston_signal_emit_mutable(&output->destroy_signal, output);
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2017-12-04 16:28:13 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link)
|
|
|
|
weston_head_remove_global(head);
|
2017-03-30 15:19:45 +03:00
|
|
|
|
|
|
|
compositor->output_id_pool &= ~(1u << output->id);
|
|
|
|
output->id = 0xffffffff; /* invalid */
|
2016-09-30 15:11:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the output scale for a given output.
|
|
|
|
*
|
|
|
|
* \param output The weston_output object that the scale is set for.
|
|
|
|
* \param scale Scale factor for the given output.
|
|
|
|
*
|
|
|
|
* It only supports setting scale for an output that
|
|
|
|
* is not enabled and it can only be ran once.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_set_scale(struct weston_output *output,
|
|
|
|
int32_t scale)
|
|
|
|
{
|
|
|
|
/* We can only set scale on a disabled output */
|
|
|
|
assert(!output->enabled);
|
|
|
|
|
|
|
|
/* We only want to set scale once */
|
|
|
|
assert(!output->scale);
|
|
|
|
|
|
|
|
output->scale = scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets the output transform for a given output.
|
|
|
|
*
|
|
|
|
* \param output The weston_output object that the transform is set for.
|
|
|
|
* \param transform Transform value for the given output.
|
|
|
|
*
|
|
|
|
* Refer to wl_output::transform section located at
|
|
|
|
* https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output
|
|
|
|
* for list of values that can be passed to this function.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2019-06-11 01:15:35 +03:00
|
|
|
* \ingroup output
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_set_transform(struct weston_output *output,
|
|
|
|
uint32_t transform)
|
|
|
|
{
|
2017-06-25 15:21:39 +03:00
|
|
|
struct weston_pointer_motion_event ev;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
pixman_region32_t old_region;
|
|
|
|
int mid_x, mid_y;
|
2017-03-28 16:27:25 +03:00
|
|
|
struct weston_head *head;
|
|
|
|
int ver;
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2017-06-25 15:21:39 +03:00
|
|
|
if (!output->enabled && output->transform == UINT32_MAX) {
|
|
|
|
output->transform = transform;
|
|
|
|
return;
|
|
|
|
}
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2017-06-25 15:21:39 +03:00
|
|
|
weston_output_transform_scale_init(output, transform, output->scale);
|
|
|
|
|
|
|
|
pixman_region32_init(&old_region);
|
|
|
|
pixman_region32_copy(&old_region, &output->region);
|
|
|
|
|
|
|
|
weston_output_init_geometry(output, output->x, output->y);
|
|
|
|
|
|
|
|
output->dirty = 1;
|
|
|
|
|
|
|
|
/* Notify clients of the change for output transform. */
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
wl_resource_for_each(resource, &head->resource_list) {
|
|
|
|
wl_output_send_geometry(resource,
|
|
|
|
output->x,
|
|
|
|
output->y,
|
|
|
|
head->mm_width,
|
|
|
|
head->mm_height,
|
|
|
|
head->subpixel,
|
|
|
|
head->make,
|
|
|
|
head->model,
|
|
|
|
output->transform);
|
|
|
|
|
|
|
|
ver = wl_resource_get_version(resource);
|
|
|
|
if (ver >= WL_OUTPUT_DONE_SINCE_VERSION)
|
|
|
|
wl_output_send_done(resource);
|
|
|
|
}
|
2019-03-29 15:01:06 +03:00
|
|
|
wl_resource_for_each(resource, &head->xdg_output_resource_list) {
|
|
|
|
zxdg_output_v1_send_logical_position(resource,
|
|
|
|
output->x,
|
|
|
|
output->y);
|
|
|
|
zxdg_output_v1_send_logical_size(resource,
|
|
|
|
output->width,
|
|
|
|
output->height);
|
|
|
|
zxdg_output_v1_send_done(resource);
|
|
|
|
}
|
2017-06-25 15:21:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we must ensure that pointers are inside output, otherwise they disappear */
|
|
|
|
mid_x = output->x + output->width / 2;
|
|
|
|
mid_y = output->y + output->height / 2;
|
|
|
|
|
|
|
|
ev.mask = WESTON_POINTER_MOTION_ABS;
|
|
|
|
ev.x = wl_fixed_to_double(wl_fixed_from_int(mid_x));
|
|
|
|
ev.y = wl_fixed_to_double(wl_fixed_from_int(mid_y));
|
|
|
|
|
|
|
|
wl_list_for_each(seat, &output->compositor->seat_list, link) {
|
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
|
|
|
if (pointer && pixman_region32_contains_point(&old_region,
|
|
|
|
wl_fixed_to_int(pointer->x),
|
|
|
|
wl_fixed_to_int(pointer->y),
|
|
|
|
NULL))
|
|
|
|
weston_pointer_move(pointer, &ev);
|
|
|
|
}
|
2016-09-30 15:11:02 +03:00
|
|
|
}
|
|
|
|
|
2021-06-08 14:17:44 +03:00
|
|
|
/** Set output's color profile
|
|
|
|
*
|
|
|
|
* \param output The output to change.
|
|
|
|
* \param cprof The color profile to set. Can be NULL for default sRGB profile.
|
|
|
|
* \return True on success, or false on failure.
|
|
|
|
*
|
|
|
|
* Calling this function changes the color profile of the output. This causes
|
|
|
|
* all existing weston_color_transform objects related to this output via
|
|
|
|
* paint nodes to be unreferenced and later re-created on demand.
|
|
|
|
*
|
|
|
|
* This function may not be called from within weston_output_repaint().
|
|
|
|
*
|
|
|
|
* On failure, nothing is changed.
|
|
|
|
*
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_output_set_color_profile(struct weston_output *output,
|
|
|
|
struct weston_color_profile *cprof)
|
|
|
|
{
|
|
|
|
struct weston_color_profile *old;
|
|
|
|
struct weston_paint_node *pnode;
|
|
|
|
|
|
|
|
old = output->color_profile;
|
|
|
|
output->color_profile = weston_color_profile_ref(cprof);
|
|
|
|
|
|
|
|
if (output->enabled) {
|
2022-04-29 11:20:34 +03:00
|
|
|
if (!weston_output_set_color_outcome(output)) {
|
2021-06-08 14:17:44 +03:00
|
|
|
/* Failed, roll back */
|
|
|
|
weston_color_profile_unref(output->color_profile);
|
|
|
|
output->color_profile = old;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove outdated cached color transformations */
|
|
|
|
wl_list_for_each(pnode, &output->paint_node_list, output_link) {
|
|
|
|
weston_surface_color_transform_fini(&pnode->surf_xform);
|
|
|
|
pnode->surf_xform_valid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_color_profile_unref(old);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-08 14:47:54 +03:00
|
|
|
/** Set EOTF mode on an output
|
|
|
|
*
|
|
|
|
* \param output The output to modify, must be in disabled state.
|
|
|
|
* \param eotf_mode The EOTF mode to set.
|
|
|
|
*
|
|
|
|
* Setting the output EOTF mode is used for turning HDR on/off. There are
|
|
|
|
* multiple modes for HDR on, see enum weston_eotf_mode. This is the high level
|
|
|
|
* choice on how to drive a video sink (monitor), either in the traditional
|
|
|
|
* SDR mode or in one of the HDR modes.
|
|
|
|
*
|
|
|
|
* After attaching heads to an output, you can find out the possibly supported
|
|
|
|
* EOTF modes with weston_output_get_supported_eotf_modes().
|
|
|
|
*
|
|
|
|
* This function does not check whether the given eotf_mode is actually
|
|
|
|
* supported on the output. Enabling an output with an unsupported EOTF mode
|
|
|
|
* has undefined visual results.
|
|
|
|
*
|
|
|
|
* The initial EOTF mode is SDR.
|
|
|
|
*
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_set_eotf_mode(struct weston_output *output,
|
|
|
|
enum weston_eotf_mode eotf_mode)
|
|
|
|
{
|
|
|
|
assert(!output->enabled);
|
|
|
|
|
|
|
|
output->eotf_mode = eotf_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get EOTF mode of an output
|
|
|
|
*
|
|
|
|
* \param output The output to query.
|
|
|
|
* \return The EOTF mode.
|
|
|
|
*
|
|
|
|
* \sa weston_output_set_eotf_mode
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
|
|
|
WL_EXPORT enum weston_eotf_mode
|
|
|
|
weston_output_get_eotf_mode(const struct weston_output *output)
|
|
|
|
{
|
|
|
|
return output->eotf_mode;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
/** Initializes a weston_output object with enough data so
|
|
|
|
** an output can be configured.
|
|
|
|
*
|
|
|
|
* \param output The weston_output object to initialize
|
|
|
|
* \param compositor The compositor instance.
|
2017-04-03 13:18:13 +03:00
|
|
|
* \param name Name for the output (the string is copied).
|
2016-09-30 15:11:02 +03:00
|
|
|
*
|
|
|
|
* Sets initial values for fields that are expected to be
|
|
|
|
* configured either by compositors or backends.
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2017-04-03 13:18:13 +03:00
|
|
|
* The name is used in logs, and can be used by compositors as a configuration
|
|
|
|
* identifier.
|
|
|
|
*
|
2019-06-11 01:15:35 +03:00
|
|
|
* \ingroup output
|
2017-03-29 16:53:50 +03:00
|
|
|
* \internal
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
2016-09-30 15:11:12 +03:00
|
|
|
weston_output_init(struct weston_output *output,
|
2017-04-03 13:18:13 +03:00
|
|
|
struct weston_compositor *compositor,
|
|
|
|
const char *name)
|
2016-09-30 15:11:02 +03:00
|
|
|
{
|
|
|
|
output->compositor = compositor;
|
|
|
|
output->destroying = 0;
|
2017-04-03 13:18:13 +03:00
|
|
|
output->name = strdup(name);
|
2016-09-30 15:11:02 +03:00
|
|
|
wl_list_init(&output->link);
|
2017-11-07 11:15:01 +03:00
|
|
|
wl_signal_init(&output->user_destroy_signal);
|
2016-09-30 15:11:02 +03:00
|
|
|
output->enabled = false;
|
2021-07-08 14:47:54 +03:00
|
|
|
output->eotf_mode = WESTON_EOTF_MODE_SDR;
|
2019-03-25 15:27:59 +03:00
|
|
|
output->desired_protection = WESTON_HDCP_DISABLE;
|
2019-04-03 07:44:59 +03:00
|
|
|
output->allow_protection = true;
|
2016-09-30 15:11:02 +03:00
|
|
|
|
2017-03-28 16:27:25 +03:00
|
|
|
wl_list_init(&output->head_list);
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
/* Add some (in)sane defaults which can be used
|
|
|
|
* for checking if an output was properly configured
|
|
|
|
*/
|
|
|
|
output->scale = 0;
|
|
|
|
/* Can't use -1 on uint32_t and 0 is valid enum value */
|
|
|
|
output->transform = UINT32_MAX;
|
2017-03-30 16:04:58 +03:00
|
|
|
|
|
|
|
pixman_region32_init(&output->region);
|
2017-09-06 16:47:52 +03:00
|
|
|
wl_list_init(&output->mode_list);
|
2016-09-30 15:11:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Adds weston_output object to pending output list.
|
|
|
|
*
|
|
|
|
* \param output The weston_output object to add
|
|
|
|
* \param compositor The compositor instance.
|
|
|
|
*
|
2017-08-16 12:07:14 +03:00
|
|
|
* The opposite of this operation is built into weston_output_release().
|
2017-03-29 16:53:50 +03:00
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-03-29 16:53:50 +03:00
|
|
|
* \internal
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_add_pending_output(struct weston_output *output,
|
|
|
|
struct weston_compositor *compositor)
|
|
|
|
{
|
2017-03-29 17:14:00 +03:00
|
|
|
assert(output->disable);
|
|
|
|
assert(output->enable);
|
|
|
|
|
2017-03-29 16:20:19 +03:00
|
|
|
wl_list_remove(&output->link);
|
2016-09-30 15:11:02 +03:00
|
|
|
wl_list_insert(compositor->pending_output_list.prev, &output->link);
|
|
|
|
}
|
|
|
|
|
2017-11-02 15:03:11 +03:00
|
|
|
/** Create a string with the attached heads' names.
|
|
|
|
*
|
|
|
|
* The string must be free()'d.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
|
|
|
* \ingroup output
|
2017-11-02 15:03:11 +03:00
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
weston_output_create_heads_string(struct weston_output *output)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char *str = NULL;
|
|
|
|
size_t size = 0;
|
|
|
|
struct weston_head *head;
|
|
|
|
const char *sep = "";
|
|
|
|
|
|
|
|
fp = open_memstream(&str, &size);
|
|
|
|
if (!fp)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
fprintf(fp, "%s%s", sep, head->name);
|
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
/** Constructs a weston_output object that can be used by the compositor.
|
|
|
|
*
|
2017-03-30 15:11:25 +03:00
|
|
|
* \param output The weston_output object that needs to be enabled. Must not
|
2017-08-23 16:00:21 +03:00
|
|
|
* be enabled already. Must have at least one head attached.
|
2016-09-30 15:11:02 +03:00
|
|
|
*
|
|
|
|
* Output coordinates are calculated and each new output is by default
|
|
|
|
* assigned to the right of previous one.
|
|
|
|
*
|
2022-01-26 18:33:30 +03:00
|
|
|
* Sets up the transformation, and geometry of the output using the
|
|
|
|
* properties that need to be configured by the compositor.
|
2016-09-30 15:11:02 +03:00
|
|
|
*
|
|
|
|
* Establishes a repaint timer for the output with the relevant display
|
|
|
|
* object's event loop. See output_repaint_timer_handler().
|
|
|
|
*
|
|
|
|
* The output is assigned an ID. Weston can support up to 32 distinct
|
|
|
|
* outputs, with IDs numbered from 0-31; the compositor's output_id_pool
|
|
|
|
* is referred to and used to find the first available ID number, and
|
|
|
|
* then this ID is marked as used in output_id_pool.
|
|
|
|
*
|
|
|
|
* The output is also assigned a Wayland global with the wl_output
|
|
|
|
* external interface.
|
|
|
|
*
|
|
|
|
* Backend specific function is called to set up the output output.
|
|
|
|
*
|
|
|
|
* Output is added to the compositor's output list
|
|
|
|
*
|
|
|
|
* If the backend specific function fails, the weston_output object
|
|
|
|
* is returned to a state it was before calling this function and
|
|
|
|
* is added to the compositor's pending_output_list in case it needs
|
|
|
|
* to be reconfigured or just so it can be destroyed at shutdown.
|
|
|
|
*
|
|
|
|
* 0 is returned on success, -1 on failure.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
|
|
|
* \ingroup output
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_output_enable(struct weston_output *output)
|
|
|
|
{
|
2016-09-30 15:11:11 +03:00
|
|
|
struct weston_compositor *c = output->compositor;
|
2016-09-30 15:11:02 +03:00
|
|
|
struct weston_output *iterator;
|
2017-08-24 16:08:49 +03:00
|
|
|
struct weston_head *head;
|
2017-11-02 15:03:11 +03:00
|
|
|
char *head_names;
|
2016-09-30 15:11:02 +03:00
|
|
|
int x = 0, y = 0;
|
|
|
|
|
2017-03-30 15:11:25 +03:00
|
|
|
if (output->enabled) {
|
|
|
|
weston_log("Error: attempt to enable an enabled output '%s'\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-08-23 16:00:21 +03:00
|
|
|
if (wl_list_empty(&output->head_list)) {
|
|
|
|
weston_log("Error: cannot enable output '%s' without heads.\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-09-14 16:17:59 +03:00
|
|
|
if (wl_list_empty(&output->mode_list) || !output->current_mode) {
|
|
|
|
weston_log("Error: no video mode for output '%s'.\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:08:49 +03:00
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
assert(head->make);
|
|
|
|
assert(head->model);
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:11 +03:00
|
|
|
iterator = container_of(c->output_list.prev,
|
2016-09-30 15:11:02 +03:00
|
|
|
struct weston_output, link);
|
|
|
|
|
2016-09-30 15:11:11 +03:00
|
|
|
if (!wl_list_empty(&c->output_list))
|
2016-09-30 15:11:02 +03:00
|
|
|
x = iterator->x + iterator->width;
|
|
|
|
|
|
|
|
/* Make sure the scale is set up */
|
|
|
|
assert(output->scale);
|
|
|
|
|
|
|
|
/* Make sure we have a transform set */
|
|
|
|
assert(output->transform != UINT32_MAX);
|
|
|
|
|
2016-09-30 15:11:11 +03:00
|
|
|
output->x = x;
|
|
|
|
output->y = y;
|
|
|
|
output->dirty = 1;
|
|
|
|
output->original_scale = output->scale;
|
|
|
|
|
2019-11-04 18:53:46 +03:00
|
|
|
wl_signal_init(&output->frame_signal);
|
|
|
|
wl_signal_init(&output->destroy_signal);
|
|
|
|
|
2016-09-30 15:11:11 +03:00
|
|
|
weston_output_transform_scale_init(output, output->transform, output->scale);
|
|
|
|
|
|
|
|
weston_output_init_geometry(output, x, y);
|
|
|
|
weston_output_damage(output);
|
|
|
|
|
|
|
|
wl_list_init(&output->animation_list);
|
|
|
|
wl_list_init(&output->feedback_list);
|
2021-04-30 14:48:52 +03:00
|
|
|
wl_list_init(&output->paint_node_list);
|
2021-04-30 17:41:29 +03:00
|
|
|
wl_list_init(&output->paint_node_z_order_list);
|
2016-09-30 15:11:11 +03:00
|
|
|
|
2021-07-08 14:47:54 +03:00
|
|
|
weston_log("Output '%s' attempts EOTF mode: %s\n", output->name,
|
|
|
|
weston_eotf_mode_to_str(output->eotf_mode));
|
|
|
|
|
2022-04-29 11:20:34 +03:00
|
|
|
if (!weston_output_set_color_outcome(output))
|
2021-02-25 13:03:28 +03:00
|
|
|
return -1;
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
/* Enable the output (set up the crtc or create a
|
|
|
|
* window representing the output, set up the
|
|
|
|
* renderer, etc)
|
|
|
|
*/
|
|
|
|
if (output->enable(output) < 0) {
|
|
|
|
weston_log("Enabling output \"%s\" failed.\n", output->name);
|
2022-04-28 15:25:00 +03:00
|
|
|
weston_output_color_outcome_destroy(&output->color_outcome);
|
2016-09-30 15:11:02 +03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_compositor_add_output(output->compositor, output);
|
|
|
|
|
2017-11-02 15:03:11 +03:00
|
|
|
head_names = weston_output_create_heads_string(output);
|
|
|
|
weston_log("Output '%s' enabled with head(s) %s\n",
|
|
|
|
output->name, head_names);
|
|
|
|
free(head_names);
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Converts a weston_output object to a pending output state, so it
|
|
|
|
** can be configured again or destroyed.
|
|
|
|
*
|
|
|
|
* \param output The weston_output object that needs to be disabled.
|
|
|
|
*
|
|
|
|
* Calls a backend specific function to disable an output, in case
|
|
|
|
* such function exists.
|
|
|
|
*
|
2017-03-29 15:45:46 +03:00
|
|
|
* The backend specific disable function may choose to postpone the disabling
|
|
|
|
* by returning a negative value, in which case this function returns early.
|
|
|
|
* In that case the backend will guarantee the output will be disabled soon
|
|
|
|
* by the backend calling this function again. One must not attempt to re-enable
|
|
|
|
* the output until that happens.
|
|
|
|
*
|
|
|
|
* Otherwise, if the output is being used by the compositor, it is removed
|
2016-09-30 15:11:02 +03:00
|
|
|
* from weston's output_list (see weston_compositor_remove_output())
|
|
|
|
* and is returned to a state it was before weston_output_enable()
|
|
|
|
* was ran (see weston_output_enable_undo()).
|
|
|
|
*
|
2017-03-29 15:45:46 +03:00
|
|
|
* See weston_output_init() for more information on the
|
|
|
|
* state output is returned to.
|
2017-03-30 15:11:25 +03:00
|
|
|
*
|
|
|
|
* If the output has never been enabled yet, this function can still be
|
|
|
|
* called to ensure that the output is actually turned off rather than left
|
|
|
|
* in the state it was discovered in.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
|
|
|
* \ingroup output
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_disable(struct weston_output *output)
|
|
|
|
{
|
|
|
|
/* Should we rename this? */
|
|
|
|
output->destroying = 1;
|
|
|
|
|
2017-03-29 15:45:46 +03:00
|
|
|
/* Disable is called unconditionally also for not-enabled outputs,
|
|
|
|
* because at compositor start-up, if there is an output that is
|
|
|
|
* already on but the compositor wants to turn it off, we have to
|
|
|
|
* forward the turn-off to the backend so it knows to do it.
|
|
|
|
* The backend cannot initially turn off everything, because it
|
|
|
|
* would cause unnecessary mode-sets for all outputs the compositor
|
|
|
|
* wants to be on.
|
|
|
|
*/
|
2016-09-30 15:11:02 +03:00
|
|
|
if (output->disable(output) < 0)
|
|
|
|
return;
|
|
|
|
|
2021-06-09 16:14:45 +03:00
|
|
|
if (output->enabled) {
|
2016-09-30 15:11:02 +03:00
|
|
|
weston_compositor_remove_output(output);
|
|
|
|
|
2021-06-09 16:14:45 +03:00
|
|
|
assert(wl_list_empty(&output->paint_node_list));
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
output->destroying = 0;
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:29:36 +03:00
|
|
|
/** Forces a synchronous call to heads_changed hook
|
2016-09-30 15:11:02 +03:00
|
|
|
*
|
|
|
|
* \param compositor The compositor instance
|
2017-08-17 17:29:36 +03:00
|
|
|
*
|
|
|
|
* If there are new or changed heads, calls the heads_changed hook and
|
|
|
|
* returns after the hook returns.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2016-09-30 15:11:02 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
2017-08-17 17:29:36 +03:00
|
|
|
weston_compositor_flush_heads_changed(struct weston_compositor *compositor)
|
2016-09-30 15:11:02 +03:00
|
|
|
{
|
2017-08-15 13:00:02 +03:00
|
|
|
if (compositor->heads_changed_source) {
|
|
|
|
wl_event_source_remove(compositor->heads_changed_source);
|
|
|
|
weston_compositor_call_heads_changed(compositor);
|
|
|
|
}
|
2016-09-30 15:11:02 +03:00
|
|
|
}
|
|
|
|
|
2017-11-07 11:15:01 +03:00
|
|
|
/** Add destroy callback for an output
|
|
|
|
*
|
|
|
|
* \param output The output to watch.
|
|
|
|
* \param listener The listener to add. The \c notify member must be set.
|
|
|
|
*
|
|
|
|
* The listener callback will be called when user destroys an output. This
|
|
|
|
* may be delayed by a backend in some cases. The main purpose of the
|
|
|
|
* listener is to allow hooking up custom data to the output. The custom data
|
|
|
|
* can be fetched via weston_output_get_destroy_listener() followed by
|
|
|
|
* container_of().
|
|
|
|
*
|
|
|
|
* The \c data argument to the notify callback is the weston_output being
|
|
|
|
* destroyed.
|
|
|
|
*
|
|
|
|
* @note This is for the final destruction of an output, not when it gets
|
|
|
|
* disabled. If you want to keep track of enabled outputs, this is not it.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2017-11-07 11:15:01 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_add_destroy_listener(struct weston_output *output,
|
|
|
|
struct wl_listener *listener)
|
|
|
|
{
|
|
|
|
wl_signal_add(&output->user_destroy_signal, listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Look up destroy listener for an output
|
|
|
|
*
|
|
|
|
* \param output The output to query.
|
|
|
|
* \param notify The notify function used used for the added destroy listener.
|
|
|
|
* \return The listener, or NULL if not found.
|
|
|
|
*
|
|
|
|
* This looks up the previously added destroy listener struct based on the
|
|
|
|
* notify function it has. The listener can be used to access user data
|
|
|
|
* through \c container_of().
|
|
|
|
*
|
|
|
|
* \sa wl_signal_get() weston_output_add_destroy_listener()
|
2019-06-11 01:15:35 +03:00
|
|
|
* \ingroup output
|
2017-11-07 11:15:01 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct wl_listener *
|
|
|
|
weston_output_get_destroy_listener(struct weston_output *output,
|
|
|
|
wl_notify_func_t notify)
|
|
|
|
{
|
|
|
|
return wl_signal_get(&output->user_destroy_signal, notify);
|
|
|
|
}
|
|
|
|
|
2017-03-29 16:53:50 +03:00
|
|
|
/** Uninitialize an output
|
|
|
|
*
|
|
|
|
* Removes the output from the list of enabled outputs if necessary, but
|
|
|
|
* does not call the backend's output disable function. The output will no
|
|
|
|
* longer be in the list of pending outputs either.
|
|
|
|
*
|
|
|
|
* All fields of weston_output become uninitialized, i.e. should not be used
|
|
|
|
* anymore. The caller can free the memory after this.
|
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2017-03-29 16:53:50 +03:00
|
|
|
* \internal
|
|
|
|
*/
|
2016-09-30 15:11:02 +03:00
|
|
|
WL_EXPORT void
|
2017-08-16 12:07:14 +03:00
|
|
|
weston_output_release(struct weston_output *output)
|
2016-09-30 15:11:02 +03:00
|
|
|
{
|
2017-03-28 16:27:25 +03:00
|
|
|
struct weston_head *head, *tmp;
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
output->destroying = 1;
|
|
|
|
|
2021-12-09 15:07:21 +03:00
|
|
|
weston_signal_emit_mutable(&output->user_destroy_signal, output);
|
2017-11-07 11:15:01 +03:00
|
|
|
|
2017-10-26 14:33:59 +03:00
|
|
|
if (output->idle_repaint_source)
|
|
|
|
wl_event_source_remove(output->idle_repaint_source);
|
|
|
|
|
2017-03-30 16:04:58 +03:00
|
|
|
if (output->enabled)
|
2016-09-30 15:11:02 +03:00
|
|
|
weston_compositor_remove_output(output);
|
|
|
|
|
2021-06-08 14:17:44 +03:00
|
|
|
weston_color_profile_unref(output->color_profile);
|
2022-04-28 15:25:00 +03:00
|
|
|
assert(output->color_outcome == NULL);
|
2021-06-08 14:17:44 +03:00
|
|
|
|
2017-03-30 16:04:58 +03:00
|
|
|
pixman_region32_fini(&output->region);
|
2017-03-29 16:20:19 +03:00
|
|
|
wl_list_remove(&output->link);
|
2017-03-28 16:27:25 +03:00
|
|
|
|
|
|
|
wl_list_for_each_safe(head, tmp, &output->head_list, output_link)
|
|
|
|
weston_head_detach(head);
|
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
free(output->name);
|
|
|
|
}
|
|
|
|
|
2017-11-02 15:11:53 +03:00
|
|
|
/** Find an output by its given name
|
|
|
|
*
|
|
|
|
* \param compositor The compositor to search in.
|
|
|
|
* \param name The output name to search for.
|
|
|
|
* \return An existing output with the given name, or NULL if not found.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-11-02 15:11:53 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_output *
|
|
|
|
weston_compositor_find_output_by_name(struct weston_compositor *compositor,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link)
|
|
|
|
if (strcmp(output->name, name) == 0)
|
|
|
|
return output;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->pending_output_list, link)
|
|
|
|
if (strcmp(output->name, name) == 0)
|
|
|
|
return output;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Create a named output
|
|
|
|
*
|
|
|
|
* \param compositor The compositor.
|
|
|
|
* \param name The name for the output.
|
|
|
|
* \return A new \c weston_output, or NULL on failure.
|
|
|
|
*
|
|
|
|
* This creates a new weston_output that starts with no heads attached.
|
|
|
|
*
|
|
|
|
* An output must be configured and it must have at least one head before
|
|
|
|
* it can be enabled.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-11-02 15:11:53 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_output *
|
|
|
|
weston_compositor_create_output(struct weston_compositor *compositor,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
assert(compositor->backend->create_output);
|
|
|
|
|
|
|
|
if (weston_compositor_find_output_by_name(compositor, name)) {
|
|
|
|
weston_log("Warning: attempted to create an output with a "
|
|
|
|
"duplicate name '%s'.\n", name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return compositor->backend->create_output(compositor, name);
|
|
|
|
}
|
|
|
|
|
2017-08-16 10:39:17 +03:00
|
|
|
/** Create an output for an unused head
|
|
|
|
*
|
|
|
|
* \param compositor The compositor.
|
|
|
|
* \param head The head to attach to the output.
|
|
|
|
* \return A new \c weston_output, or NULL on failure.
|
|
|
|
*
|
|
|
|
* This creates a new weston_output that starts with the given head attached.
|
|
|
|
* The output inherits the name of the head. The head must not be already
|
|
|
|
* attached to another output.
|
|
|
|
*
|
|
|
|
* An output must be configured before it can be enabled.
|
|
|
|
*
|
2019-06-11 16:08:55 +03:00
|
|
|
* \ingroup compositor
|
2017-08-16 10:39:17 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_output *
|
|
|
|
weston_compositor_create_output_with_head(struct weston_compositor *compositor,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
|
2017-11-02 15:11:53 +03:00
|
|
|
output = weston_compositor_create_output(compositor, head->name);
|
2017-08-16 10:39:17 +03:00
|
|
|
if (!output)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (weston_output_attach_head(output, head) < 0) {
|
2017-10-27 12:07:49 +03:00
|
|
|
weston_output_destroy(output);
|
2017-08-16 10:39:17 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroy an output
|
|
|
|
*
|
|
|
|
* \param output The output to destroy.
|
|
|
|
*
|
|
|
|
* The heads attached to the given output are detached and become unused again.
|
|
|
|
*
|
|
|
|
* It is not necessary to explicitly destroy all outputs at compositor exit.
|
2020-01-28 01:12:01 +03:00
|
|
|
* weston_compositor_destroy() will automatically destroy any remaining
|
2017-08-16 10:39:17 +03:00
|
|
|
* outputs.
|
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2017-08-16 10:39:17 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_destroy(struct weston_output *output)
|
|
|
|
{
|
|
|
|
output->destroy(output);
|
|
|
|
}
|
|
|
|
|
2017-04-04 16:36:07 +03:00
|
|
|
/** When you need a head...
|
|
|
|
*
|
|
|
|
* This function is a hack, used until all code has been converted to become
|
|
|
|
* multi-head aware.
|
|
|
|
*
|
|
|
|
* \param output The weston_output whose head to get.
|
|
|
|
* \return The first head in the output's list.
|
2019-06-11 01:15:35 +03:00
|
|
|
*
|
2020-12-18 01:10:13 +03:00
|
|
|
* \ingroup output
|
2017-04-04 16:36:07 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_head *
|
|
|
|
weston_output_get_first_head(struct weston_output *output)
|
|
|
|
{
|
|
|
|
if (wl_list_empty(&output->head_list))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(output->head_list.next,
|
|
|
|
struct weston_head, output_link);
|
|
|
|
}
|
|
|
|
|
2019-04-03 07:44:59 +03:00
|
|
|
/** Allow/Disallow content-protection support for an output
|
|
|
|
*
|
|
|
|
* This function sets the allow_protection member for an output. Setting of
|
|
|
|
* this field will allow the compositor to attempt content-protection for this
|
|
|
|
* output, for a backend that supports the content-protection protocol.
|
|
|
|
*
|
|
|
|
* \param output The weston_output for whom the content-protection is to be
|
|
|
|
* allowed.
|
|
|
|
* \param allow_protection The bool value which is to be set.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_allow_protection(struct weston_output *output,
|
|
|
|
bool allow_protection)
|
|
|
|
{
|
|
|
|
output->allow_protection = allow_protection;
|
|
|
|
}
|
|
|
|
|
2021-07-08 14:47:54 +03:00
|
|
|
/** Get supported EOTF modes as a bit mask
|
|
|
|
*
|
|
|
|
* \param output The output to query.
|
|
|
|
* \return A bit mask with values from enum weston_eotf_mode or'ed together.
|
|
|
|
*
|
|
|
|
* Returns the bit mask of the EOTF modes that all the currently attached
|
|
|
|
* heads claim to support. Adding or removing heads may change the result.
|
|
|
|
* An output can be queried regrdless of whether it is enabled or disabled.
|
|
|
|
*
|
|
|
|
* If no heads are attached, no EOTF modes are deemed supported.
|
|
|
|
*
|
|
|
|
* \ingroup output
|
|
|
|
*/
|
|
|
|
WL_EXPORT uint32_t
|
|
|
|
weston_output_get_supported_eotf_modes(struct weston_output *output)
|
|
|
|
{
|
|
|
|
uint32_t eotf_modes = WESTON_EOTF_MODE_ALL_MASK;
|
|
|
|
struct weston_head *head;
|
|
|
|
|
|
|
|
if (wl_list_empty(&output->head_list))
|
|
|
|
return WESTON_EOTF_MODE_NONE;
|
|
|
|
|
|
|
|
wl_list_for_each(head, &output->head_list, output_link)
|
|
|
|
eotf_modes = eotf_modes & head->supported_eotf_mask;
|
|
|
|
|
|
|
|
return eotf_modes;
|
|
|
|
}
|
|
|
|
|
2019-03-29 15:01:06 +03:00
|
|
|
static void
|
|
|
|
xdg_output_unlist(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_output_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_output_v1_interface xdg_output_interface = {
|
|
|
|
xdg_output_destroy
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_output_manager_destroy(struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_output_manager_get_xdg_output(struct wl_client *client,
|
|
|
|
struct wl_resource *manager,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *output_resource)
|
|
|
|
{
|
|
|
|
int version = wl_resource_get_version(manager);
|
|
|
|
struct weston_head *head = wl_resource_get_user_data(output_resource);
|
|
|
|
struct weston_output *output = head->output;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_resource_create(client, &zxdg_output_v1_interface,
|
|
|
|
version, id);
|
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_insert(&head->xdg_output_resource_list,
|
|
|
|
wl_resource_get_link(resource));
|
|
|
|
|
|
|
|
wl_resource_set_implementation(resource, &xdg_output_interface,
|
|
|
|
NULL, xdg_output_unlist);
|
|
|
|
|
|
|
|
zxdg_output_v1_send_logical_position(resource, output->x, output->y);
|
|
|
|
zxdg_output_v1_send_logical_size(resource,
|
|
|
|
output->width,
|
|
|
|
output->height);
|
|
|
|
if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION)
|
|
|
|
zxdg_output_v1_send_name(resource, head->name);
|
|
|
|
|
|
|
|
zxdg_output_v1_send_done(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_output_manager_v1_interface xdg_output_manager_interface = {
|
|
|
|
xdg_output_manager_destroy,
|
|
|
|
xdg_output_manager_get_xdg_output
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_xdg_output_manager(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_resource_create(client, &zxdg_output_manager_v1_interface,
|
|
|
|
version, id);
|
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_set_implementation(resource, &xdg_output_manager_interface,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:19:45 +04:00
|
|
|
static void
|
2014-01-08 17:39:17 +04:00
|
|
|
destroy_viewport(struct wl_resource *resource)
|
2013-11-26 21:19:45 +04:00
|
|
|
{
|
2013-11-26 21:19:46 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
|
2016-04-22 14:14:38 +03:00
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
2014-01-08 17:39:17 +04:00
|
|
|
surface->viewport_resource = NULL;
|
2014-03-14 16:38:16 +04:00
|
|
|
surface->pending.buffer_viewport.buffer.src_width =
|
|
|
|
wl_fixed_from_int(-1);
|
|
|
|
surface->pending.buffer_viewport.surface.width = -1;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2013-11-26 21:19:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-08 17:39:17 +04:00
|
|
|
viewport_destroy(struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-11-26 21:19:45 +04:00
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2014-03-14 16:38:17 +04:00
|
|
|
static void
|
|
|
|
viewport_set_source(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
wl_fixed_t src_x,
|
|
|
|
wl_fixed_t src_y,
|
|
|
|
wl_fixed_t src_width,
|
|
|
|
wl_fixed_t src_height)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
|
2016-04-22 14:14:38 +03:00
|
|
|
if (!surface) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WP_VIEWPORT_ERROR_NO_SURFACE,
|
|
|
|
"wl_surface for this viewport is no longer exists");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(surface->viewport_resource == resource);
|
2016-04-26 14:42:11 +03:00
|
|
|
assert(surface->resource);
|
2014-03-14 16:38:17 +04:00
|
|
|
|
2014-04-04 15:22:12 +04:00
|
|
|
if (src_width == wl_fixed_from_int(-1) &&
|
2016-04-26 14:42:11 +03:00
|
|
|
src_height == wl_fixed_from_int(-1) &&
|
|
|
|
src_x == wl_fixed_from_int(-1) &&
|
|
|
|
src_y == wl_fixed_from_int(-1)) {
|
|
|
|
/* unset source rect */
|
2014-03-14 16:38:17 +04:00
|
|
|
surface->pending.buffer_viewport.buffer.src_width =
|
|
|
|
wl_fixed_from_int(-1);
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2014-04-04 15:22:12 +04:00
|
|
|
return;
|
2014-03-14 16:38:17 +04:00
|
|
|
}
|
2014-04-04 15:22:12 +04:00
|
|
|
|
2016-04-26 14:42:11 +03:00
|
|
|
if (src_width <= 0 || src_height <= 0 || src_x < 0 || src_y < 0) {
|
2014-04-04 15:22:12 +04:00
|
|
|
wl_resource_post_error(resource,
|
2016-04-15 14:47:08 +03:00
|
|
|
WP_VIEWPORT_ERROR_BAD_VALUE,
|
2016-04-26 14:42:11 +03:00
|
|
|
"wl_surface@%d viewport source "
|
|
|
|
"w=%f <= 0, h=%f <= 0, x=%f < 0, or y=%f < 0",
|
|
|
|
wl_resource_get_id(surface->resource),
|
2014-04-04 15:22:12 +04:00
|
|
|
wl_fixed_to_double(src_width),
|
2016-04-26 14:42:11 +03:00
|
|
|
wl_fixed_to_double(src_height),
|
|
|
|
wl_fixed_to_double(src_x),
|
|
|
|
wl_fixed_to_double(src_y));
|
2014-04-04 15:22:12 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->pending.buffer_viewport.buffer.src_x = src_x;
|
|
|
|
surface->pending.buffer_viewport.buffer.src_y = src_y;
|
|
|
|
surface->pending.buffer_viewport.buffer.src_width = src_width;
|
|
|
|
surface->pending.buffer_viewport.buffer.src_height = src_height;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2014-03-14 16:38:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
viewport_set_destination(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t dst_width,
|
|
|
|
int32_t dst_height)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
|
2016-04-22 14:14:38 +03:00
|
|
|
if (!surface) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WP_VIEWPORT_ERROR_NO_SURFACE,
|
|
|
|
"wl_surface for this viewport no longer exists");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(surface->viewport_resource == resource);
|
2014-03-14 16:38:17 +04:00
|
|
|
|
2014-04-04 15:22:12 +04:00
|
|
|
if (dst_width == -1 && dst_height == -1) {
|
|
|
|
/* unset destination size */
|
2014-03-14 16:38:17 +04:00
|
|
|
surface->pending.buffer_viewport.surface.width = -1;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2014-04-04 15:22:12 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst_width <= 0 || dst_height <= 0) {
|
|
|
|
wl_resource_post_error(resource,
|
2016-04-15 14:47:08 +03:00
|
|
|
WP_VIEWPORT_ERROR_BAD_VALUE,
|
2014-04-04 15:22:12 +04:00
|
|
|
"destination size must be positive (%dx%d)",
|
|
|
|
dst_width, dst_height);
|
|
|
|
return;
|
2014-03-14 16:38:17 +04:00
|
|
|
}
|
2014-04-04 15:22:12 +04:00
|
|
|
|
|
|
|
surface->pending.buffer_viewport.surface.width = dst_width;
|
|
|
|
surface->pending.buffer_viewport.surface.height = dst_height;
|
2014-06-13 20:14:20 +04:00
|
|
|
surface->pending.buffer_viewport.changed = 1;
|
2014-03-14 16:38:17 +04:00
|
|
|
}
|
|
|
|
|
2016-04-15 14:47:08 +03:00
|
|
|
static const struct wp_viewport_interface viewport_interface = {
|
2014-01-08 17:39:17 +04:00
|
|
|
viewport_destroy,
|
2014-03-14 16:38:17 +04:00
|
|
|
viewport_set_source,
|
|
|
|
viewport_set_destination
|
2013-11-26 21:19:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-04-15 16:42:49 +03:00
|
|
|
viewporter_destroy(struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-11-26 21:19:45 +04:00
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-15 16:42:49 +03:00
|
|
|
viewporter_get_viewport(struct wl_client *client,
|
|
|
|
struct wl_resource *viewporter,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *surface_resource)
|
2013-11-26 21:19:45 +04:00
|
|
|
{
|
2016-04-15 16:42:49 +03:00
|
|
|
int version = wl_resource_get_version(viewporter);
|
2014-03-14 16:38:17 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
2013-11-26 21:19:45 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2014-01-08 17:39:17 +04:00
|
|
|
if (surface->viewport_resource) {
|
2016-04-15 16:42:49 +03:00
|
|
|
wl_resource_post_error(viewporter,
|
2016-04-15 14:47:08 +03:00
|
|
|
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
|
2014-01-08 17:39:17 +04:00
|
|
|
"a viewport for that surface already exists");
|
2013-11-26 21:19:46 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-15 14:47:08 +03:00
|
|
|
resource = wl_resource_create(client, &wp_viewport_interface,
|
2014-03-14 16:38:17 +04:00
|
|
|
version, id);
|
2013-11-26 21:19:45 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-08 17:39:17 +04:00
|
|
|
wl_resource_set_implementation(resource, &viewport_interface,
|
|
|
|
surface, destroy_viewport);
|
2013-11-26 21:19:46 +04:00
|
|
|
|
2014-01-08 17:39:17 +04:00
|
|
|
surface->viewport_resource = resource;
|
2013-11-26 21:19:45 +04:00
|
|
|
}
|
|
|
|
|
2016-04-15 16:42:49 +03:00
|
|
|
static const struct wp_viewporter_interface viewporter_interface = {
|
|
|
|
viewporter_destroy,
|
|
|
|
viewporter_get_viewport
|
2013-11-26 21:19:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-04-15 16:42:49 +03:00
|
|
|
bind_viewporter(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
2013-11-26 21:19:45 +04:00
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2016-04-15 14:47:08 +03:00
|
|
|
resource = wl_resource_create(client, &wp_viewporter_interface,
|
2015-11-26 23:17:47 +03:00
|
|
|
version, id);
|
2013-11-26 21:19:45 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-15 16:42:49 +03:00
|
|
|
wl_resource_set_implementation(resource, &viewporter_interface,
|
2013-11-26 21:19:45 +04:00
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-24 06:08:46 +04:00
|
|
|
static void
|
|
|
|
destroy_presentation_feedback(struct wl_resource *feedback_resource)
|
|
|
|
{
|
|
|
|
struct weston_presentation_feedback *feedback;
|
|
|
|
|
|
|
|
feedback = wl_resource_get_user_data(feedback_resource);
|
|
|
|
|
|
|
|
wl_list_remove(&feedback->link);
|
|
|
|
free(feedback);
|
|
|
|
}
|
|
|
|
|
2014-09-24 06:08:43 +04:00
|
|
|
static void
|
|
|
|
presentation_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
presentation_feedback(struct wl_client *client,
|
2014-09-24 06:08:46 +04:00
|
|
|
struct wl_resource *presentation_resource,
|
|
|
|
struct wl_resource *surface_resource,
|
2014-09-24 06:08:43 +04:00
|
|
|
uint32_t callback)
|
|
|
|
{
|
2014-09-24 06:08:46 +04:00
|
|
|
struct weston_surface *surface;
|
|
|
|
struct weston_presentation_feedback *feedback;
|
|
|
|
|
|
|
|
surface = wl_resource_get_user_data(surface_resource);
|
|
|
|
|
2014-11-21 09:21:57 +03:00
|
|
|
feedback = zalloc(sizeof *feedback);
|
|
|
|
if (feedback == NULL)
|
2014-09-24 06:08:46 +04:00
|
|
|
goto err_calloc;
|
|
|
|
|
|
|
|
feedback->resource = wl_resource_create(client,
|
2016-02-18 17:53:27 +03:00
|
|
|
&wp_presentation_feedback_interface,
|
2014-09-24 06:08:46 +04:00
|
|
|
1, callback);
|
|
|
|
if (!feedback->resource)
|
|
|
|
goto err_create;
|
|
|
|
|
|
|
|
wl_resource_set_implementation(feedback->resource, NULL, feedback,
|
|
|
|
destroy_presentation_feedback);
|
|
|
|
|
|
|
|
wl_list_insert(&surface->pending.feedback_list, &feedback->link);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
err_create:
|
|
|
|
free(feedback);
|
|
|
|
|
|
|
|
err_calloc:
|
|
|
|
wl_client_post_no_memory(client);
|
2014-09-24 06:08:43 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 17:53:27 +03:00
|
|
|
static const struct wp_presentation_interface presentation_implementation = {
|
2014-09-24 06:08:43 +04:00
|
|
|
presentation_destroy,
|
|
|
|
presentation_feedback
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_presentation(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2016-02-18 17:53:27 +03:00
|
|
|
resource = wl_resource_create(client, &wp_presentation_interface,
|
2015-11-26 23:17:47 +03:00
|
|
|
version, id);
|
2014-09-24 06:08:43 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_set_implementation(resource, &presentation_implementation,
|
|
|
|
compositor, NULL);
|
2016-02-18 17:53:27 +03:00
|
|
|
wp_presentation_send_clock_id(resource, compositor->presentation_clock);
|
2014-09-24 06:08:43 +04:00
|
|
|
}
|
|
|
|
|
2011-11-23 19:39:34 +04:00
|
|
|
static void
|
|
|
|
compositor_bind(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor *compositor = data;
|
2013-06-28 05:17:02 +04:00
|
|
|
struct wl_resource *resource;
|
2011-11-23 19:39:34 +04:00
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
resource = wl_resource_create(client, &wl_compositor_interface,
|
2015-11-26 23:17:47 +03:00
|
|
|
version, id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_set_implementation(resource, &compositor_interface,
|
|
|
|
compositor, NULL);
|
2011-11-23 19:39:34 +04:00
|
|
|
}
|
|
|
|
|
2018-07-20 11:46:24 +03:00
|
|
|
static const char *
|
|
|
|
output_repaint_status_text(struct weston_output *output)
|
|
|
|
{
|
|
|
|
switch (output->repaint_status) {
|
|
|
|
case REPAINT_NOT_SCHEDULED:
|
|
|
|
return "no repaint";
|
|
|
|
case REPAINT_BEGIN_FROM_IDLE:
|
|
|
|
return "start_repaint_loop scheduled";
|
|
|
|
case REPAINT_SCHEDULED:
|
|
|
|
return "repaint scheduled";
|
|
|
|
case REPAINT_AWAITING_COMPLETION:
|
|
|
|
return "awaiting completion";
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!"output_repaint_status_text missing enum");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
|
|
|
|
{
|
|
|
|
struct weston_buffer *buffer = view->surface->buffer_ref.buffer;
|
2022-01-14 04:36:54 +03:00
|
|
|
char *modifier_name;
|
2018-07-20 11:46:24 +03:00
|
|
|
|
|
|
|
if (!buffer) {
|
|
|
|
fprintf(fp, "\t\t[buffer not available]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-14 04:36:54 +03:00
|
|
|
switch (buffer->type) {
|
|
|
|
case WESTON_BUFFER_SHM:
|
2018-07-20 11:46:24 +03:00
|
|
|
fprintf(fp, "\t\tSHM buffer\n");
|
2022-01-14 04:36:54 +03:00
|
|
|
break;
|
|
|
|
case WESTON_BUFFER_DMABUF:
|
2018-07-20 11:46:24 +03:00
|
|
|
fprintf(fp, "\t\tdmabuf buffer\n");
|
2022-01-14 04:36:54 +03:00
|
|
|
break;
|
2022-01-15 20:47:35 +03:00
|
|
|
case WESTON_BUFFER_SOLID:
|
|
|
|
fprintf(fp, "\t\tsolid-colour buffer\n");
|
|
|
|
fprintf(fp, "\t\t\t[R %f, G %f, B %f, A %f]\n",
|
|
|
|
buffer->solid.r, buffer->solid.g, buffer->solid.b,
|
|
|
|
buffer->solid.a);
|
|
|
|
break;
|
2022-01-21 14:05:26 +03:00
|
|
|
case WESTON_BUFFER_RENDERER_OPAQUE:
|
2022-01-14 05:01:24 +03:00
|
|
|
fprintf(fp, "\t\tEGL buffer:\n");
|
|
|
|
fprintf(fp, "\t\t\t[format may be inaccurate]\n");
|
2022-01-14 04:36:54 +03:00
|
|
|
break;
|
2018-07-20 11:46:24 +03:00
|
|
|
}
|
2022-01-14 05:01:24 +03:00
|
|
|
|
2022-01-21 14:05:26 +03:00
|
|
|
if (buffer->busy_count > 0) {
|
|
|
|
fprintf(fp, "\t\t\t[%d references may use buffer content]\n",
|
|
|
|
buffer->busy_count);
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "\t\t\t[buffer has been released to client]\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer->pixel_format) {
|
|
|
|
fprintf(fp, "\t\t\tformat: 0x%lx %s\n",
|
|
|
|
(unsigned long) buffer->pixel_format->format,
|
|
|
|
buffer->pixel_format->drm_format_name);
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "\t\t\t[unknown format]\n");
|
|
|
|
}
|
2022-01-14 05:01:24 +03:00
|
|
|
|
|
|
|
modifier_name = pixel_format_get_modifier(buffer->format_modifier);
|
|
|
|
fprintf(fp, "\t\t\tmodifier: %s\n",
|
|
|
|
modifier_name ?
|
|
|
|
modifier_name : "Failed to convert to a modifier name");
|
|
|
|
free(modifier_name);
|
2022-01-21 14:05:26 +03:00
|
|
|
|
|
|
|
fprintf(fp, "\t\t\twidth: %d, height: %d\n",
|
|
|
|
buffer->width, buffer->height);
|
|
|
|
if (buffer->buffer_origin == ORIGIN_BOTTOM_LEFT)
|
|
|
|
fprintf(fp, "\t\t\tbottom-left origin\n");
|
2022-01-19 20:59:50 +03:00
|
|
|
|
|
|
|
if (buffer->direct_display)
|
|
|
|
fprintf(fp, "\t\t\tdirect-display buffer (no renderer access)\n");
|
2018-07-20 11:46:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_scene_view_print(FILE *fp, struct weston_view *view, int view_idx)
|
|
|
|
{
|
|
|
|
struct weston_compositor *ec = view->surface->compositor;
|
|
|
|
struct weston_output *output;
|
|
|
|
char desc[512];
|
|
|
|
pixman_box32_t *box;
|
|
|
|
uint32_t surface_id = 0;
|
|
|
|
pid_t pid = 0;
|
|
|
|
|
|
|
|
if (view->surface->resource) {
|
|
|
|
struct wl_resource *resource = view->surface->resource;
|
|
|
|
wl_client_get_credentials(wl_resource_get_client(resource),
|
|
|
|
&pid, NULL, NULL);
|
|
|
|
surface_id = wl_resource_get_id(view->surface->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!view->surface->get_label ||
|
|
|
|
view->surface->get_label(view->surface, desc, sizeof(desc)) < 0) {
|
|
|
|
strcpy(desc, "[no description available]");
|
|
|
|
}
|
|
|
|
fprintf(fp, "\tView %d (role %s, PID %d, surface ID %u, %s, %p):\n",
|
|
|
|
view_idx, view->surface->role_name, pid, surface_id,
|
|
|
|
desc, view);
|
|
|
|
|
|
|
|
box = pixman_region32_extents(&view->transform.boundingbox);
|
|
|
|
fprintf(fp, "\t\tposition: (%d, %d) -> (%d, %d)\n",
|
|
|
|
box->x1, box->y1, box->x2, box->y2);
|
|
|
|
box = pixman_region32_extents(&view->transform.opaque);
|
|
|
|
|
2020-08-11 17:33:35 +03:00
|
|
|
if (weston_view_is_opaque(view, &view->transform.boundingbox)) {
|
2018-07-20 11:46:24 +03:00
|
|
|
fprintf(fp, "\t\t[fully opaque]\n");
|
|
|
|
} else if (!pixman_region32_not_empty(&view->transform.opaque)) {
|
|
|
|
fprintf(fp, "\t\t[not opaque]\n");
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "\t\t[opaque: (%d, %d) -> (%d, %d)]\n",
|
|
|
|
box->x1, box->y1, box->x2, box->y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view->alpha < 1.0)
|
|
|
|
fprintf(fp, "\t\talpha: %f\n", view->alpha);
|
|
|
|
|
|
|
|
if (view->output_mask != 0) {
|
|
|
|
bool first_output = true;
|
|
|
|
fprintf(fp, "\t\toutputs: ");
|
|
|
|
wl_list_for_each(output, &ec->output_list, link) {
|
|
|
|
if (!(view->output_mask & (1 << output->id)))
|
|
|
|
continue;
|
|
|
|
fprintf(fp, "%s%d (%s)%s",
|
|
|
|
(first_output) ? "" : ", ",
|
|
|
|
output->id, output->name,
|
|
|
|
(view->output == output) ? " (primary)" : "");
|
|
|
|
first_output = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "\t\t[no outputs]");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
|
|
|
debug_scene_view_print_buffer(fp, view);
|
|
|
|
}
|
|
|
|
|
2019-02-17 23:14:23 +03:00
|
|
|
static void
|
|
|
|
debug_scene_view_print_tree(struct weston_view *view,
|
2019-03-17 19:10:09 +03:00
|
|
|
FILE *fp, int *view_idx)
|
2019-02-17 23:14:23 +03:00
|
|
|
{
|
|
|
|
struct weston_subsurface *sub;
|
|
|
|
struct weston_view *ev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* print the view first, then we recursively go on printing
|
|
|
|
* sub-surfaces. We bail out once no more sub-surfaces are available.
|
|
|
|
*/
|
2019-03-17 19:10:09 +03:00
|
|
|
debug_scene_view_print(fp, view, *view_idx);
|
2019-02-17 23:14:23 +03:00
|
|
|
|
|
|
|
/* no more sub-surfaces */
|
|
|
|
if (wl_list_empty(&view->surface->subsurface_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_for_each(sub, &view->surface->subsurface_list, parent_link) {
|
|
|
|
wl_list_for_each(ev, &sub->surface->views, surface_link) {
|
2020-04-29 10:03:15 +03:00
|
|
|
/* only print the child views of the current view */
|
|
|
|
if (ev->parent_view != view)
|
2019-02-17 23:14:23 +03:00
|
|
|
continue;
|
2019-03-17 19:10:09 +03:00
|
|
|
|
|
|
|
(*view_idx)++;
|
2019-02-17 23:14:23 +03:00
|
|
|
debug_scene_view_print_tree(ev, fp, view_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-20 11:46:24 +03:00
|
|
|
/**
|
|
|
|
* Output information on how libweston is currently composing the scene
|
|
|
|
* graph.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2018-07-20 11:46:24 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT char *
|
|
|
|
weston_compositor_print_scene_graph(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
struct weston_layer *layer;
|
|
|
|
struct timespec now;
|
|
|
|
int layer_idx = 0;
|
|
|
|
FILE *fp;
|
|
|
|
char *ret;
|
|
|
|
size_t len;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
fp = open_memstream(&ret, &len);
|
|
|
|
assert(fp);
|
|
|
|
|
|
|
|
weston_compositor_read_presentation_clock(ec, &now);
|
|
|
|
fprintf(fp, "Weston scene graph at %ld.%09ld:\n\n",
|
|
|
|
now.tv_sec, now.tv_nsec);
|
|
|
|
|
|
|
|
wl_list_for_each(output, &ec->output_list, link) {
|
|
|
|
struct weston_head *head;
|
|
|
|
int head_idx = 0;
|
|
|
|
|
|
|
|
fprintf(fp, "Output %d (%s):\n", output->id, output->name);
|
|
|
|
assert(output->enabled);
|
|
|
|
|
|
|
|
fprintf(fp, "\tposition: (%d, %d) -> (%d, %d)\n",
|
|
|
|
output->x, output->y,
|
|
|
|
output->x + output->width,
|
|
|
|
output->y + output->height);
|
|
|
|
fprintf(fp, "\tmode: %dx%d@%.3fHz\n",
|
|
|
|
output->current_mode->width,
|
|
|
|
output->current_mode->height,
|
|
|
|
output->current_mode->refresh / 1000.0);
|
|
|
|
fprintf(fp, "\tscale: %d\n", output->scale);
|
|
|
|
|
|
|
|
fprintf(fp, "\trepaint status: %s\n",
|
|
|
|
output_repaint_status_text(output));
|
|
|
|
if (output->repaint_status == REPAINT_SCHEDULED)
|
|
|
|
fprintf(fp, "\tnext repaint: %ld.%09ld\n",
|
|
|
|
output->next_repaint.tv_sec,
|
|
|
|
output->next_repaint.tv_nsec);
|
|
|
|
|
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
|
|
|
fprintf(fp, "\tHead %d (%s): %sconnected\n",
|
|
|
|
head_idx++, head->name,
|
|
|
|
(head->connected) ? "" : "not ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
|
|
|
wl_list_for_each(layer, &ec->layer_list, link) {
|
|
|
|
struct weston_view *view;
|
|
|
|
int view_idx = 0;
|
|
|
|
|
|
|
|
fprintf(fp, "Layer %d (pos 0x%lx):\n", layer_idx++,
|
|
|
|
(unsigned long) layer->position);
|
|
|
|
|
|
|
|
if (!weston_layer_mask_is_infinite(layer)) {
|
|
|
|
fprintf(fp, "\t[mask: (%d, %d) -> (%d,%d)]\n\n",
|
|
|
|
layer->mask.x1, layer->mask.y1,
|
|
|
|
layer->mask.x2, layer->mask.y2);
|
|
|
|
}
|
|
|
|
|
2019-03-17 19:10:09 +03:00
|
|
|
wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
|
|
|
|
debug_scene_view_print_tree(view, fp, &view_idx);
|
|
|
|
view_idx++;
|
|
|
|
}
|
2018-07-20 11:46:24 +03:00
|
|
|
|
|
|
|
if (wl_list_empty(&layer->view_list.link))
|
|
|
|
fprintf(fp, "\t[no views]\n");
|
|
|
|
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
err = fclose(fp);
|
|
|
|
assert(err == 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the 'scene-graph' debug scope is bound by a client. This
|
|
|
|
* one-shot weston-debug scope prints the current scene graph when bound,
|
|
|
|
* and then terminates the stream.
|
|
|
|
*/
|
|
|
|
static void
|
2019-07-17 15:43:53 +03:00
|
|
|
debug_scene_graph_cb(struct weston_log_subscription *sub, void *data)
|
2018-07-20 11:46:24 +03:00
|
|
|
{
|
|
|
|
struct weston_compositor *ec = data;
|
|
|
|
char *str = weston_compositor_print_scene_graph(ec);
|
|
|
|
|
2019-07-17 15:43:53 +03:00
|
|
|
weston_log_subscription_printf(sub, "%s", str);
|
2018-07-20 11:46:24 +03:00
|
|
|
free(str);
|
2019-07-17 15:43:53 +03:00
|
|
|
weston_log_subscription_complete(sub);
|
2018-07-20 11:46:24 +03:00
|
|
|
}
|
|
|
|
|
2020-10-19 22:06:22 +03:00
|
|
|
/** Retrieve testsuite data from compositor
|
|
|
|
*
|
|
|
|
* The testsuite data can be defined by the test suite of projects that uses
|
|
|
|
* libweston and given to the compositor at the moment of its creation. This
|
|
|
|
* function should be used when we need to retrieve the testsuite private data
|
|
|
|
* from the compositor.
|
|
|
|
*
|
|
|
|
* \param ec The weston compositor.
|
|
|
|
* \return The testsuite data.
|
|
|
|
*
|
|
|
|
* \ingroup compositor
|
|
|
|
* \sa weston_compositor_test_data_init
|
|
|
|
*/
|
|
|
|
WL_EXPORT void *
|
|
|
|
weston_compositor_get_test_data(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
return ec->test_data.test_private_data;
|
|
|
|
}
|
|
|
|
|
2014-10-12 00:56:24 +04:00
|
|
|
/** Create the compositor.
|
|
|
|
*
|
|
|
|
* This functions creates and initializes a compositor instance.
|
|
|
|
*
|
|
|
|
* \param display The Wayland display to be used.
|
|
|
|
* \param user_data A pointer to an object that can later be retrieved
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param log_ctx A pointer to weston_debug_compositor
|
2020-11-06 17:24:22 +03:00
|
|
|
* \param test_data Optional testsuite data, or NULL.
|
2014-10-12 00:56:24 +04:00
|
|
|
* using the \ref weston_compositor_get_user_data function.
|
|
|
|
* \return The compositor instance on success or NULL on failure.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2014-10-12 00:56:24 +04:00
|
|
|
*/
|
|
|
|
WL_EXPORT struct weston_compositor *
|
2019-04-07 17:07:58 +03:00
|
|
|
weston_compositor_create(struct wl_display *display,
|
2020-11-06 17:24:22 +03:00
|
|
|
struct weston_log_context *log_ctx, void *user_data,
|
|
|
|
const struct weston_testsuite_data *test_data)
|
2010-06-14 19:54:00 +04:00
|
|
|
{
|
2014-10-12 00:56:24 +04:00
|
|
|
struct weston_compositor *ec;
|
2010-06-14 19:54:00 +04:00
|
|
|
struct wl_event_loop *loop;
|
2013-05-14 20:48:26 +04:00
|
|
|
|
2020-01-17 16:47:49 +03:00
|
|
|
if (!log_ctx)
|
|
|
|
return NULL;
|
|
|
|
|
2014-10-12 00:56:24 +04:00
|
|
|
ec = zalloc(sizeof *ec);
|
|
|
|
if (!ec)
|
|
|
|
return NULL;
|
|
|
|
|
2020-11-06 17:24:22 +03:00
|
|
|
if (test_data)
|
|
|
|
ec->test_data = *test_data;
|
|
|
|
|
2020-01-17 16:47:49 +03:00
|
|
|
ec->weston_log_ctx = log_ctx;
|
2014-10-12 00:56:24 +04:00
|
|
|
ec->wl_display = display;
|
|
|
|
ec->user_data = user_data;
|
2012-04-12 17:55:26 +04:00
|
|
|
wl_signal_init(&ec->destroy_signal);
|
2014-04-07 09:04:50 +04:00
|
|
|
wl_signal_init(&ec->create_surface_signal);
|
2012-04-12 17:55:26 +04:00
|
|
|
wl_signal_init(&ec->activate_signal);
|
2013-06-12 22:43:21 +04:00
|
|
|
wl_signal_init(&ec->transform_signal);
|
2012-09-27 18:48:36 +04:00
|
|
|
wl_signal_init(&ec->kill_signal);
|
2013-02-21 20:35:23 +04:00
|
|
|
wl_signal_init(&ec->idle_signal);
|
|
|
|
wl_signal_init(&ec->wake_signal);
|
2012-06-21 23:52:17 +04:00
|
|
|
wl_signal_init(&ec->show_input_panel_signal);
|
|
|
|
wl_signal_init(&ec->hide_input_panel_signal);
|
2013-04-18 18:47:28 +04:00
|
|
|
wl_signal_init(&ec->update_input_panel_signal);
|
2012-11-18 22:06:42 +04:00
|
|
|
wl_signal_init(&ec->seat_created_signal);
|
2013-05-02 00:52:11 +04:00
|
|
|
wl_signal_init(&ec->output_created_signal);
|
2014-01-29 20:47:51 +04:00
|
|
|
wl_signal_init(&ec->output_destroyed_signal);
|
2014-01-29 20:47:52 +04:00
|
|
|
wl_signal_init(&ec->output_moved_signal);
|
2016-05-28 00:22:57 +03:00
|
|
|
wl_signal_init(&ec->output_resized_signal);
|
2017-08-15 13:00:02 +03:00
|
|
|
wl_signal_init(&ec->heads_changed_signal);
|
2018-03-20 14:29:40 +03:00
|
|
|
wl_signal_init(&ec->output_heads_changed_signal);
|
2013-09-18 03:02:57 +04:00
|
|
|
wl_signal_init(&ec->session_signal);
|
2019-07-10 18:40:12 +03:00
|
|
|
ec->session_active = true;
|
2008-10-09 06:51:32 +04:00
|
|
|
|
2012-04-20 06:50:08 +04:00
|
|
|
ec->output_id_pool = 0;
|
2014-10-12 01:24:25 +04:00
|
|
|
ec->repaint_msec = DEFAULT_REPAINT_WINDOW;
|
2012-04-20 06:50:08 +04:00
|
|
|
|
2014-10-18 20:42:19 +04:00
|
|
|
ec->activate_serial = 1;
|
|
|
|
|
input: introduce touch event mode for calibrator
In addition to the normal touch event processing mode, introduce a new
mode for calibrating a touchscreen input device.
In the calibration mode, normal touch event processing is skipped, and
the raw events are forwarded to the calibrator instead. The calibrator
is not yet implemented, so the calls will be added in a following patch.
To switch between modes, two functions are added, one for entering each
mode. The mode switch happens only when no touches are down on any touch
device, to avoid confusing touch grabs and clients. To realise this, the
state machine has four states: prepare and actual state for both normal
and calibrator modes.
At this point nothing will attempt to change the touch event mode.
The new calibrator mode is necessary, because when calibrating a
touchscreen, the touch events must be routed to the calibration client
directly. The touch coordinates are expected to be wrong, so they cannot
go through the normal focus surface picking. The calibrator code also
cannot use the normal touch grab interface, because it needs to be able
to distinguish between different physical touch input devices, even if
they are part of the same weston_seat. This requirement makes
calibration special enough to warrant the new mode, a sort of "super
grab".
Co-developed by Louis-Francis and Pekka.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-29 04:42:47 +03:00
|
|
|
ec->touch_mode = WESTON_TOUCH_MODE_NORMAL;
|
|
|
|
|
2019-03-28 12:35:42 +03:00
|
|
|
ec->content_protection = NULL;
|
|
|
|
|
2015-11-26 23:17:48 +03:00
|
|
|
if (!wl_global_create(ec->wl_display, &wl_compositor_interface, 4,
|
2013-07-09 03:03:57 +04:00
|
|
|
ec, compositor_bind))
|
2014-10-12 00:56:24 +04:00
|
|
|
goto fail;
|
2008-12-22 07:37:12 +03:00
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
if (!wl_global_create(ec->wl_display, &wl_subcompositor_interface, 1,
|
2013-07-09 03:03:57 +04:00
|
|
|
ec, bind_subcompositor))
|
2014-10-12 00:56:24 +04:00
|
|
|
goto fail;
|
compositor: introduce sub-surfaces
Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code
Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.
For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.
Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.
The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.
Features still lacking are:
- full-surface alpha support for compound windows
Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy
Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
wl_subsurface protocol object inert, if one destroys the corresponding
wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
.place_below to be applied when the parent surface state is applied,
instead of immediately. This conforms with the protocol specification
now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2013-04-25 14:57:42 +04:00
|
|
|
|
2016-04-15 14:47:08 +03:00
|
|
|
if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
|
2016-04-15 16:42:49 +03:00
|
|
|
ec, bind_viewporter))
|
2014-10-12 00:56:24 +04:00
|
|
|
goto fail;
|
2013-11-26 21:19:45 +04:00
|
|
|
|
2019-03-29 15:01:06 +03:00
|
|
|
if (!wl_global_create(ec->wl_display, &zxdg_output_manager_v1_interface, 2,
|
|
|
|
ec, bind_xdg_output_manager))
|
|
|
|
goto fail;
|
|
|
|
|
2016-02-18 17:53:27 +03:00
|
|
|
if (!wl_global_create(ec->wl_display, &wp_presentation_interface, 1,
|
2014-09-24 06:08:43 +04:00
|
|
|
ec, bind_presentation))
|
2014-10-12 00:56:24 +04:00
|
|
|
goto fail;
|
2014-09-24 06:08:43 +04:00
|
|
|
|
2014-10-22 23:21:17 +04:00
|
|
|
if (weston_input_init(ec) != 0)
|
|
|
|
goto fail;
|
|
|
|
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
wl_list_init(&ec->view_list);
|
2013-03-05 19:30:27 +04:00
|
|
|
wl_list_init(&ec->plane_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
wl_list_init(&ec->layer_list);
|
|
|
|
wl_list_init(&ec->seat_list);
|
2016-09-30 15:11:02 +03:00
|
|
|
wl_list_init(&ec->pending_output_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
wl_list_init(&ec->output_list);
|
2017-08-14 16:05:35 +03:00
|
|
|
wl_list_init(&ec->head_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
wl_list_init(&ec->key_binding_list);
|
2013-11-19 14:37:12 +04:00
|
|
|
wl_list_init(&ec->modifier_binding_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
wl_list_init(&ec->button_binding_list);
|
2013-10-03 19:43:04 +04:00
|
|
|
wl_list_init(&ec->touch_binding_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
wl_list_init(&ec->axis_binding_list);
|
2012-11-08 19:20:45 +04:00
|
|
|
wl_list_init(&ec->debug_binding_list);
|
2012-06-22 17:04:36 +04:00
|
|
|
|
2016-06-29 12:54:26 +03:00
|
|
|
wl_list_init(&ec->plugin_api_list);
|
|
|
|
|
2013-10-23 09:58:31 +04:00
|
|
|
weston_plane_init(&ec->primary_plane, ec, 0, 0);
|
2013-03-05 19:30:27 +04:00
|
|
|
weston_compositor_stack_plane(ec, &ec->primary_plane, NULL);
|
2012-08-03 19:30:18 +04:00
|
|
|
|
2014-10-12 00:56:24 +04:00
|
|
|
wl_data_device_manager_init(ec->wl_display);
|
|
|
|
|
|
|
|
wl_display_init_shm(ec->wl_display);
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(ec->wl_display);
|
|
|
|
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
|
2017-03-01 14:34:08 +03:00
|
|
|
ec->repaint_timer =
|
|
|
|
wl_event_loop_add_timer(loop, output_repaint_timer_handler,
|
|
|
|
ec);
|
2014-10-12 00:56:24 +04:00
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
weston_layer_init(&ec->fade_layer, ec);
|
|
|
|
weston_layer_init(&ec->cursor_layer, ec);
|
|
|
|
|
|
|
|
weston_layer_set_position(&ec->fade_layer, WESTON_LAYER_POSITION_FADE);
|
|
|
|
weston_layer_set_position(&ec->cursor_layer,
|
|
|
|
WESTON_LAYER_POSITION_CURSOR);
|
2014-10-12 00:56:24 +04:00
|
|
|
|
2018-07-20 11:46:24 +03:00
|
|
|
ec->debug_scene =
|
2019-12-26 22:35:49 +03:00
|
|
|
weston_compositor_add_log_scope(ec, "scene-graph",
|
|
|
|
"Scene graph details\n",
|
|
|
|
debug_scene_graph_cb, NULL,
|
|
|
|
ec);
|
2018-07-20 11:46:24 +03:00
|
|
|
|
2019-09-05 14:31:01 +03:00
|
|
|
ec->timeline =
|
2019-12-26 22:35:49 +03:00
|
|
|
weston_compositor_add_log_scope(ec, "timeline",
|
|
|
|
"Timeline event points\n",
|
|
|
|
weston_timeline_create_subscription,
|
|
|
|
weston_timeline_destroy_subscription,
|
|
|
|
ec);
|
2022-03-09 13:06:33 +03:00
|
|
|
ec->libseat_debug =
|
|
|
|
weston_compositor_add_log_scope(ec, "libseat-debug",
|
|
|
|
"libseat debug messages\n",
|
|
|
|
NULL, NULL, NULL);
|
2014-10-12 00:56:24 +04:00
|
|
|
return ec;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
free(ec);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_shutdown
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2011-08-30 13:32:47 +04:00
|
|
|
WL_EXPORT void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_compositor_shutdown(struct weston_compositor *ec)
|
2011-08-30 00:52:23 +04:00
|
|
|
{
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output *output, *next;
|
2011-08-30 00:52:23 +04:00
|
|
|
|
2012-01-02 18:06:56 +04:00
|
|
|
wl_event_source_remove(ec->idle_source);
|
2019-08-12 22:03:29 +03:00
|
|
|
wl_event_source_remove(ec->repaint_timer);
|
2012-01-02 18:06:56 +04:00
|
|
|
|
2022-04-07 20:04:25 +03:00
|
|
|
if (ec->touch_calibration)
|
|
|
|
weston_compositor_destroy_touch_calibrator(ec);
|
|
|
|
|
2011-08-30 00:52:23 +04:00
|
|
|
/* Destroy all outputs associated with this compositor */
|
2011-12-19 00:27:40 +04:00
|
|
|
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
2011-08-30 00:52:23 +04:00
|
|
|
output->destroy(output);
|
2012-01-02 17:47:07 +04:00
|
|
|
|
2016-09-30 15:11:02 +03:00
|
|
|
/* Destroy all pending outputs associated with this compositor */
|
|
|
|
wl_list_for_each_safe(output, next, &ec->pending_output_list, link)
|
|
|
|
output->destroy(output);
|
|
|
|
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
/* Color manager objects may have renderer hooks */
|
|
|
|
if (ec->color_manager) {
|
|
|
|
ec->color_manager->destroy(ec->color_manager);
|
|
|
|
ec->color_manager = NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-20 23:07:00 +04:00
|
|
|
if (ec->renderer)
|
|
|
|
ec->renderer->destroy(ec);
|
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_binding_list_destroy_all(&ec->key_binding_list);
|
2015-07-17 07:07:42 +03:00
|
|
|
weston_binding_list_destroy_all(&ec->modifier_binding_list);
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_binding_list_destroy_all(&ec->button_binding_list);
|
2013-10-03 19:43:04 +04:00
|
|
|
weston_binding_list_destroy_all(&ec->touch_binding_list);
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_binding_list_destroy_all(&ec->axis_binding_list);
|
2012-11-08 19:20:45 +04:00
|
|
|
weston_binding_list_destroy_all(&ec->debug_binding_list);
|
2012-01-02 18:06:56 +04:00
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
weston_plane_release(&ec->primary_plane);
|
2021-05-14 14:29:40 +03:00
|
|
|
|
|
|
|
weston_layer_fini(&ec->fade_layer);
|
|
|
|
weston_layer_fini(&ec->cursor_layer);
|
|
|
|
|
|
|
|
if (!wl_list_empty(&ec->layer_list))
|
|
|
|
weston_log("BUG: layer_list is not empty after shutdown. Calls to weston_layer_fini() are missing somwhere.\n");
|
2011-08-30 00:52:23 +04:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_exit_with_code
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2014-10-29 21:44:33 +03:00
|
|
|
WL_EXPORT void
|
2019-10-16 23:02:59 +03:00
|
|
|
weston_compositor_exit_with_code(struct weston_compositor *compositor,
|
2014-10-29 21:44:33 +03:00
|
|
|
int exit_code)
|
|
|
|
{
|
2014-11-18 16:57:04 +03:00
|
|
|
if (compositor->exit_code == EXIT_SUCCESS)
|
|
|
|
compositor->exit_code = exit_code;
|
|
|
|
|
2014-10-12 00:56:24 +04:00
|
|
|
weston_compositor_exit(compositor);
|
2014-10-29 21:44:33 +03:00
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_set_default_pointer_grab
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2013-11-15 02:42:53 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
|
|
|
|
const struct weston_pointer_grab_interface *interface)
|
|
|
|
{
|
|
|
|
struct weston_seat *seat;
|
|
|
|
|
|
|
|
ec->default_pointer_grab = interface;
|
|
|
|
wl_list_for_each(seat, &ec->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
|
|
|
|
if (pointer)
|
|
|
|
weston_pointer_set_default_grab(pointer, interface);
|
2013-11-15 02:42:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_set_presentation_clock
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2014-09-24 06:08:45 +04:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
|
|
|
|
clockid_t clk_id)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
if (clock_gettime(clk_id, &ts) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
compositor->presentation_clock = clk_id;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** For choosing the software clock, when the display hardware or API
|
2014-09-24 06:08:45 +04:00
|
|
|
* does not expose a compatible presentation timestamp.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2014-09-24 06:08:45 +04:00
|
|
|
*/
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_compositor_set_presentation_clock_software(
|
|
|
|
struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
/* In order of preference */
|
|
|
|
static const clockid_t clocks[] = {
|
|
|
|
CLOCK_MONOTONIC_RAW, /* no jumps, no crawling */
|
|
|
|
CLOCK_MONOTONIC_COARSE, /* no jumps, may crawl, fast & coarse */
|
|
|
|
CLOCK_MONOTONIC, /* no jumps, may crawl */
|
|
|
|
};
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(clocks); i++)
|
|
|
|
if (weston_compositor_set_presentation_clock(compositor,
|
|
|
|
clocks[i]) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
weston_log("Error: no suitable presentation clock available.\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-03-18 13:17:26 +03:00
|
|
|
/** Read the current time from the Presentation clock
|
|
|
|
*
|
|
|
|
* \param compositor
|
2019-06-12 16:05:44 +03:00
|
|
|
* \param[out] ts The current time.
|
2015-03-18 13:17:26 +03:00
|
|
|
*
|
|
|
|
* \note Reading the current time in user space is always imprecise to some
|
|
|
|
* degree.
|
|
|
|
*
|
|
|
|
* This function is never meant to fail. If reading the clock does fail,
|
|
|
|
* an error message is logged and a zero time is returned. Callers are not
|
|
|
|
* supposed to detect or react to failures.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2015-03-18 13:17:26 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_read_presentation_clock(
|
|
|
|
const struct weston_compositor *compositor,
|
|
|
|
struct timespec *ts)
|
|
|
|
{
|
|
|
|
static bool warned;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = clock_gettime(compositor->presentation_clock, ts);
|
|
|
|
if (ret < 0) {
|
|
|
|
ts->tv_sec = 0;
|
|
|
|
ts->tv_nsec = 0;
|
|
|
|
|
|
|
|
if (!warned)
|
|
|
|
weston_log("Error: failure to read "
|
2019-04-27 00:57:31 +03:00
|
|
|
"the presentation clock %#x: '%s' (%d)\n",
|
|
|
|
compositor->presentation_clock,
|
|
|
|
strerror(errno), errno);
|
2015-03-18 13:17:26 +03:00
|
|
|
warned = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-29 22:18:40 +04:00
|
|
|
/** Import dmabuf buffer into current renderer
|
|
|
|
*
|
|
|
|
* \param compositor
|
|
|
|
* \param buffer the dmabuf buffer to import
|
|
|
|
* \return true on usable buffers, false otherwise
|
|
|
|
*
|
|
|
|
* This function tests that the linux_dmabuf_buffer is usable
|
|
|
|
* for the current renderer. Returns false on unusable buffers. Usually
|
|
|
|
* usability is tested by importing the dmabufs for composition.
|
|
|
|
*
|
|
|
|
* This hook is also used for detecting if the renderer supports
|
|
|
|
* dmabufs at all. If the renderer hook is NULL, dmabufs are not
|
|
|
|
* supported.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2014-09-29 22:18:40 +04:00
|
|
|
WL_EXPORT bool
|
|
|
|
weston_compositor_import_dmabuf(struct weston_compositor *compositor,
|
|
|
|
struct linux_dmabuf_buffer *buffer)
|
|
|
|
{
|
|
|
|
struct weston_renderer *renderer;
|
|
|
|
|
|
|
|
renderer = compositor->renderer;
|
|
|
|
|
|
|
|
if (renderer->import_dmabuf == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return renderer->import_dmabuf(compositor, buffer);
|
|
|
|
}
|
|
|
|
|
2019-11-16 21:26:52 +03:00
|
|
|
WL_EXPORT bool
|
|
|
|
weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
|
|
|
|
struct linux_dmabuf_buffer *buffer)
|
|
|
|
{
|
|
|
|
struct weston_backend *backend = compositor->backend;
|
|
|
|
|
|
|
|
if (backend->can_scanout_dmabuf == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return backend->can_scanout_dmabuf(compositor, buffer);
|
|
|
|
}
|
|
|
|
|
2013-02-16 05:53:20 +04:00
|
|
|
WL_EXPORT void
|
|
|
|
weston_version(int *major, int *minor, int *micro)
|
|
|
|
{
|
|
|
|
*major = WESTON_VERSION_MAJOR;
|
|
|
|
*minor = WESTON_VERSION_MINOR;
|
|
|
|
*micro = WESTON_VERSION_MICRO;
|
|
|
|
}
|
|
|
|
|
2016-11-24 23:45:45 +03:00
|
|
|
/**
|
|
|
|
* Attempts to find a module path from the module map specified in the
|
|
|
|
* environment. If found, writes the full path into the path variable.
|
|
|
|
*
|
|
|
|
* The module map is a string in environment variable WESTON_MODULE_MAP, where
|
|
|
|
* each entry is of the form "name=path" and entries are separated by
|
|
|
|
* semicolons. Whitespace is significant.
|
|
|
|
*
|
|
|
|
* \param name The name to search for.
|
|
|
|
* \param path Where the path is written to if found.
|
|
|
|
* \param path_len Allocated bytes at \c path .
|
|
|
|
* \returns The length of the string written to path on success, or 0 if the
|
|
|
|
* module was not specified in the environment map or path_len was too small.
|
|
|
|
*/
|
|
|
|
WL_EXPORT size_t
|
|
|
|
weston_module_path_from_env(const char *name, char *path, size_t path_len)
|
|
|
|
{
|
|
|
|
const char *mapping = getenv("WESTON_MODULE_MAP");
|
|
|
|
const char *end;
|
|
|
|
const int name_len = strlen(name);
|
|
|
|
|
|
|
|
if (!mapping)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
end = mapping + strlen(mapping);
|
|
|
|
while (mapping < end && *mapping) {
|
|
|
|
const char *filename, *next;
|
|
|
|
|
|
|
|
/* early out: impossibly short string */
|
|
|
|
if (end - mapping < name_len + 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
filename = &mapping[name_len + 1];
|
|
|
|
next = strchrnul(mapping, ';');
|
|
|
|
|
|
|
|
if (strncmp(mapping, name, name_len) == 0 &&
|
|
|
|
mapping[name_len] == '=') {
|
|
|
|
size_t file_len = next - filename; /* no trailing NUL */
|
|
|
|
if (file_len >= path_len)
|
|
|
|
return 0;
|
|
|
|
strncpy(path, filename, file_len);
|
|
|
|
path[file_len] = '\0';
|
|
|
|
return file_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
mapping = next + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-14 16:57:11 +04:00
|
|
|
WL_EXPORT void *
|
|
|
|
weston_load_module(const char *name, const char *entrypoint)
|
2011-05-03 06:09:20 +04:00
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
void *module, *init;
|
2016-11-28 15:13:54 +03:00
|
|
|
size_t len;
|
2011-05-03 06:09:20 +04:00
|
|
|
|
2014-01-18 01:19:01 +04:00
|
|
|
if (name == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2015-06-08 19:46:54 +03:00
|
|
|
if (name[0] != '/') {
|
2016-11-24 23:45:45 +03:00
|
|
|
len = weston_module_path_from_env(name, path, sizeof path);
|
|
|
|
if (len == 0)
|
2016-11-28 15:13:54 +03:00
|
|
|
len = snprintf(path, sizeof path, "%s/%s",
|
|
|
|
LIBWESTON_MODULEDIR, name);
|
2015-06-08 19:46:54 +03:00
|
|
|
} else {
|
2016-11-28 15:13:54 +03:00
|
|
|
len = snprintf(path, sizeof path, "%s", name);
|
2015-06-08 19:46:54 +03:00
|
|
|
}
|
2011-05-03 06:09:20 +04:00
|
|
|
|
2016-11-28 15:13:54 +03:00
|
|
|
/* snprintf returns the length of the string it would've written,
|
|
|
|
* _excluding_ the NUL byte. So even being equal to the size of
|
|
|
|
* our buffer is an error here. */
|
|
|
|
if (len >= sizeof path)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-12 20:21:01 +04:00
|
|
|
module = dlopen(path, RTLD_NOW | RTLD_NOLOAD);
|
|
|
|
if (module) {
|
|
|
|
weston_log("Module '%s' already loaded\n", path);
|
2019-11-04 15:07:51 +03:00
|
|
|
} else {
|
|
|
|
weston_log("Loading module '%s'\n", path);
|
|
|
|
module = dlopen(path, RTLD_NOW);
|
|
|
|
if (!module) {
|
|
|
|
weston_log("Failed to load module: %s\n", dlerror());
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-05-03 06:09:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
init = dlsym(module, entrypoint);
|
|
|
|
if (!init) {
|
2012-06-11 15:06:04 +04:00
|
|
|
weston_log("Failed to lookup init function: %s\n", dlerror());
|
2012-12-05 22:47:10 +04:00
|
|
|
dlclose(module);
|
2011-05-03 06:09:20 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return init;
|
|
|
|
}
|
|
|
|
|
2019-11-06 13:59:32 +03:00
|
|
|
/** Add a compositor destroy listener only once
|
|
|
|
*
|
|
|
|
* \param compositor The compositor whose destroy to watch for.
|
|
|
|
* \param listener The listener struct to initialize.
|
|
|
|
* \param destroy_handler The callback when compositor is destroyed.
|
|
|
|
* \return True if listener is added, or false if there already is a listener
|
|
|
|
* with the given \c destroy_handler.
|
|
|
|
*
|
|
|
|
* This function does nothing and returns false if the given callback function
|
|
|
|
* is already present in the weston_compositor destroy callbacks list.
|
|
|
|
* Otherwise, this function initializes the given listener with the given
|
|
|
|
* callback pointer and adds it to the compositor's destroy callbacks list.
|
|
|
|
*
|
|
|
|
* This can be used to ensure that plugin initialization is done only once
|
|
|
|
* in case the same plugin is loaded multiple times. If this function returns
|
|
|
|
* false, the plugin should be already initialized successfully.
|
|
|
|
*
|
|
|
|
* All plugins should register a destroy listener for cleaning up. Note, that
|
|
|
|
* the plugin destruction order is not guaranteed: plugins that depend on other
|
|
|
|
* plugins must be able to be torn down in arbitrary order.
|
|
|
|
*
|
2020-01-28 01:12:01 +03:00
|
|
|
* \sa weston_compositor_destroy
|
2019-11-06 13:59:32 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT bool
|
|
|
|
weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor,
|
|
|
|
struct wl_listener *listener,
|
|
|
|
wl_notify_func_t destroy_handler)
|
|
|
|
{
|
|
|
|
if (wl_signal_get(&compositor->destroy_signal, destroy_handler))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
listener->notify = destroy_handler;
|
|
|
|
wl_signal_add(&compositor->destroy_signal, listener);
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-12 00:56:24 +04:00
|
|
|
|
2020-01-28 01:12:01 +03:00
|
|
|
/** Destroys the compositor.
|
2014-10-12 00:56:24 +04:00
|
|
|
*
|
2020-01-28 01:12:01 +03:00
|
|
|
* This function cleans up the compositor state and then destroys it.
|
2014-10-12 00:56:24 +04:00
|
|
|
*
|
2020-01-28 01:12:01 +03:00
|
|
|
* @param compositor The compositor to be destroyed.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
2019-06-24 12:00:47 +03:00
|
|
|
* @ingroup compositor
|
2014-10-12 00:56:24 +04:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
2020-01-28 01:12:01 +03:00
|
|
|
weston_compositor_destroy(struct weston_compositor *compositor)
|
2014-10-12 00:56:24 +04:00
|
|
|
{
|
|
|
|
/* prevent further rendering while shutting down */
|
|
|
|
compositor->state = WESTON_COMPOSITOR_OFFSCREEN;
|
|
|
|
|
2021-12-09 15:07:21 +03:00
|
|
|
weston_signal_emit_mutable(&compositor->destroy_signal, compositor);
|
2014-10-12 00:56:24 +04:00
|
|
|
|
|
|
|
weston_compositor_xkb_destroy(compositor);
|
|
|
|
|
2015-10-03 16:25:15 +03:00
|
|
|
if (compositor->backend)
|
|
|
|
compositor->backend->destroy(compositor);
|
2016-06-29 12:54:26 +03:00
|
|
|
|
2017-08-14 16:05:35 +03:00
|
|
|
/* The backend is responsible for destroying the heads. */
|
|
|
|
assert(wl_list_empty(&compositor->head_list));
|
|
|
|
|
2016-06-29 12:54:26 +03:00
|
|
|
weston_plugin_api_destroy_list(compositor);
|
|
|
|
|
2017-08-15 13:00:02 +03:00
|
|
|
if (compositor->heads_changed_source)
|
|
|
|
wl_event_source_remove(compositor->heads_changed_source);
|
|
|
|
|
2019-12-18 21:52:18 +03:00
|
|
|
weston_log_scope_destroy(compositor->debug_scene);
|
2018-07-20 11:46:24 +03:00
|
|
|
compositor->debug_scene = NULL;
|
2019-09-05 14:31:01 +03:00
|
|
|
|
2019-12-18 21:52:18 +03:00
|
|
|
weston_log_scope_destroy(compositor->timeline);
|
2019-09-05 14:31:01 +03:00
|
|
|
compositor->timeline = NULL;
|
2017-10-12 14:13:42 +03:00
|
|
|
|
2022-03-09 13:06:33 +03:00
|
|
|
weston_log_scope_destroy(compositor->libseat_debug);
|
|
|
|
compositor->libseat_debug = NULL;
|
|
|
|
|
2021-01-19 01:36:48 +03:00
|
|
|
if (compositor->default_dmabuf_feedback) {
|
|
|
|
weston_dmabuf_feedback_destroy(compositor->default_dmabuf_feedback);
|
|
|
|
weston_dmabuf_feedback_format_table_destroy(compositor->dmabuf_feedback_format_table);
|
|
|
|
}
|
|
|
|
|
2014-10-12 00:56:24 +04:00
|
|
|
free(compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Instruct the compositor to exit.
|
|
|
|
*
|
|
|
|
* This functions does not directly destroy the compositor object, it merely
|
|
|
|
* command it to start the tear down process. It is not guaranteed that the
|
|
|
|
* tear down will happen immediately.
|
|
|
|
*
|
|
|
|
* \param compositor The compositor to tear down.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2014-10-12 00:56:24 +04:00
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_compositor_exit(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
compositor->exit(compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Return the user data stored in the compositor.
|
|
|
|
*
|
|
|
|
* This function returns the user data pointer set with user_data parameter
|
|
|
|
* to the \ref weston_compositor_create function.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2014-10-12 00:56:24 +04:00
|
|
|
*/
|
|
|
|
WL_EXPORT void *
|
|
|
|
weston_compositor_get_user_data(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
return compositor->user_data;
|
|
|
|
}
|
2016-06-03 14:49:54 +03:00
|
|
|
|
2016-06-03 15:23:46 +03:00
|
|
|
static const char * const backend_map[] = {
|
|
|
|
[WESTON_BACKEND_DRM] = "drm-backend.so",
|
|
|
|
[WESTON_BACKEND_HEADLESS] = "headless-backend.so",
|
|
|
|
[WESTON_BACKEND_RDP] = "rdp-backend.so",
|
|
|
|
[WESTON_BACKEND_WAYLAND] = "wayland-backend.so",
|
|
|
|
[WESTON_BACKEND_X11] = "x11-backend.so",
|
|
|
|
};
|
|
|
|
|
2016-06-03 14:49:54 +03:00
|
|
|
/** Load a backend into a weston_compositor
|
|
|
|
*
|
|
|
|
* A backend must be loaded to make a weston_compositor work. A backend
|
|
|
|
* provides input and output capabilities, and determines the renderer to use.
|
|
|
|
*
|
|
|
|
* \param compositor A compositor that has not had a backend loaded yet.
|
|
|
|
* \param backend Name of the backend file.
|
|
|
|
* \param config_base A pointer to a backend-specific configuration
|
|
|
|
* structure's 'base' member.
|
|
|
|
*
|
|
|
|
* \return 0 on success, or -1 on error.
|
2019-06-11 16:08:55 +03:00
|
|
|
*
|
|
|
|
* \ingroup compositor
|
2016-06-03 14:49:54 +03:00
|
|
|
*/
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_compositor_load_backend(struct weston_compositor *compositor,
|
2016-06-03 15:23:46 +03:00
|
|
|
enum weston_compositor_backend backend,
|
2016-06-03 14:49:54 +03:00
|
|
|
struct weston_backend_config *config_base)
|
|
|
|
{
|
|
|
|
int (*backend_init)(struct weston_compositor *c,
|
|
|
|
struct weston_backend_config *config_base);
|
|
|
|
|
2017-08-29 17:04:12 +03:00
|
|
|
if (compositor->backend) {
|
|
|
|
weston_log("Error: attempt to load a backend when one is already loaded\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-07-10 12:00:53 +03:00
|
|
|
if (backend >= ARRAY_LENGTH(backend_map))
|
2016-06-03 15:23:46 +03:00
|
|
|
return -1;
|
|
|
|
|
2016-12-02 16:08:44 +03:00
|
|
|
backend_init = weston_load_module(backend_map[backend], "weston_backend_init");
|
2016-06-03 14:49:54 +03:00
|
|
|
if (!backend_init)
|
|
|
|
return -1;
|
|
|
|
|
2017-08-29 17:04:12 +03:00
|
|
|
if (backend_init(compositor, config_base) < 0) {
|
|
|
|
compositor->backend = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985
This starts building the framework required for implementing color
management.
The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.
weston_color_manager interface is incomplete and will be extended later.
Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.
This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.
As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.
As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.
Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.
As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.
This design is inspired by Sebastian Wick's Weston color management
work.
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:03:28 +03:00
|
|
|
if (!compositor->color_manager) {
|
|
|
|
compositor->color_manager =
|
|
|
|
weston_color_manager_noop_create(compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!compositor->color_manager)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!compositor->color_manager->init(compositor->color_manager))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
weston_log("Color manager: %s\n", compositor->color_manager->name);
|
|
|
|
|
2017-08-29 17:04:12 +03:00
|
|
|
return 0;
|
2016-06-03 14:49:54 +03:00
|
|
|
}
|
2016-06-29 12:54:27 +03:00
|
|
|
|
2019-06-11 16:08:55 +03:00
|
|
|
/** weston_compositor_load_xwayland
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
2016-06-29 12:54:27 +03:00
|
|
|
WL_EXPORT int
|
|
|
|
weston_compositor_load_xwayland(struct weston_compositor *compositor)
|
|
|
|
{
|
2016-12-02 16:20:35 +03:00
|
|
|
int (*module_init)(struct weston_compositor *ec);
|
2016-06-29 12:54:27 +03:00
|
|
|
|
2016-12-02 16:20:35 +03:00
|
|
|
module_init = weston_load_module("xwayland.so", "weston_module_init");
|
2016-06-29 12:54:27 +03:00
|
|
|
if (!module_init)
|
|
|
|
return -1;
|
2016-12-02 16:20:35 +03:00
|
|
|
if (module_init(compositor) < 0)
|
2016-06-29 12:54:27 +03:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
2018-10-10 17:14:55 +03:00
|
|
|
|
2021-03-29 14:11:49 +03:00
|
|
|
/** Load Little CMS color manager plugin
|
|
|
|
*
|
|
|
|
* Calling this function before loading any backend sets Little CMS
|
|
|
|
* as the active color matching module (CMM) instead of the default no-op
|
|
|
|
* color manager.
|
|
|
|
*
|
|
|
|
* \ingroup compositor
|
|
|
|
*/
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_compositor_load_color_manager(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct weston_color_manager *
|
|
|
|
(*cm_create)(struct weston_compositor *compositor);
|
|
|
|
|
|
|
|
if (compositor->color_manager) {
|
|
|
|
weston_log("Error: Color manager '%s' is loaded, cannot load another.\n",
|
|
|
|
compositor->color_manager->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cm_create = weston_load_module("color-lcms.so", "weston_color_manager_create");
|
|
|
|
if (!cm_create) {
|
|
|
|
weston_log("Error: Could not load color-lcms.so.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
compositor->color_manager = cm_create(compositor);
|
|
|
|
if (!compositor->color_manager) {
|
|
|
|
weston_log("Error: loading color-lcms.so failed.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-10 17:14:55 +03:00
|
|
|
/** Resolve an internal compositor error by disconnecting the client.
|
|
|
|
*
|
|
|
|
* This function is used in cases when the wl_buffer turns out
|
|
|
|
* unusable and there is no fallback path.
|
|
|
|
*
|
|
|
|
* It is possible the fault is caused by a compositor bug, the underlying
|
|
|
|
* graphics stack bug or normal behaviour, or perhaps a client mistake.
|
|
|
|
* In any case, the options are to either composite garbage or nothing,
|
|
|
|
* or disconnect the client. This is a helper function for the latter.
|
|
|
|
*
|
|
|
|
* The error is sent as an INVALID_OBJECT error on the client's wl_display.
|
|
|
|
*
|
|
|
|
* \param buffer The weston buffer that is unusable.
|
|
|
|
* \param msg A custom error message attached to the protocol error.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_buffer_send_server_error(struct weston_buffer *buffer,
|
|
|
|
const char *msg)
|
|
|
|
{
|
|
|
|
struct wl_client *client;
|
|
|
|
struct wl_resource *display_resource;
|
|
|
|
uint32_t id;
|
|
|
|
|
|
|
|
assert(buffer->resource);
|
|
|
|
id = wl_resource_get_id(buffer->resource);
|
|
|
|
client = wl_resource_get_client(buffer->resource);
|
|
|
|
display_resource = wl_client_get_object(client, 1);
|
|
|
|
|
|
|
|
assert(display_resource);
|
|
|
|
wl_resource_post_error(display_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"server error with "
|
|
|
|
"wl_buffer@%u: %s", id, msg);
|
|
|
|
}
|
2019-07-08 09:16:42 +03:00
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_disable_planes_incr(struct weston_output *output)
|
|
|
|
{
|
|
|
|
output->disable_planes++;
|
2019-07-08 12:42:19 +03:00
|
|
|
/*
|
|
|
|
* If disable_planes changes from 0 to non-zero, it means some type of
|
|
|
|
* recording of content has started, and therefore protection level of
|
|
|
|
* the protected surfaces must be updated to avoid the recording of
|
|
|
|
* the protected content.
|
|
|
|
*/
|
|
|
|
if (output->disable_planes == 1)
|
|
|
|
weston_schedule_surface_protection_update(output->compositor);
|
2019-07-08 09:16:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_output_disable_planes_decr(struct weston_output *output)
|
|
|
|
{
|
|
|
|
output->disable_planes--;
|
2019-07-08 12:42:19 +03:00
|
|
|
/*
|
|
|
|
* If disable_planes changes from non-zero to 0, it means no content
|
|
|
|
* recording is going on any more, and the protected and surfaces can be
|
|
|
|
* shown without any apprehensions about content being recorded.
|
|
|
|
*/
|
|
|
|
if (output->disable_planes == 0)
|
|
|
|
weston_schedule_surface_protection_update(output->compositor);
|
|
|
|
|
2019-07-08 09:16:42 +03:00
|
|
|
}
|