mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
backend/wayland: add support for direct scan-out
Closes: https://github.com/swaywm/wlroots/issues/1830
This commit is contained in:
parent
cbb2781fed
commit
5bddb5a909
4 changed files with 134 additions and 4 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <wlr/config.h>
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
#include <wlr/backend/interface.h>
|
||||
|
|
@ -16,8 +17,9 @@
|
|||
|
||||
#include "backend/wayland.h"
|
||||
#include "util/signal.h"
|
||||
#include "xdg-decoration-unstable-v1-client-protocol.h"
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
#include "pointer-gestures-unstable-v1-client-protocol.h"
|
||||
#include "xdg-decoration-unstable-v1-client-protocol.h"
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
|
||||
|
|
@ -59,6 +61,29 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
|||
xdg_wm_base_handle_ping,
|
||||
};
|
||||
|
||||
static void linux_dmabuf_v1_handle_format(void *data,
|
||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf_v1, uint32_t format) {
|
||||
// Note, this event is deprecated
|
||||
struct wlr_wl_backend *wl = data;
|
||||
|
||||
wlr_drm_format_set_add(&wl->linux_dmabuf_v1_formats, format,
|
||||
DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
static void linux_dmabuf_v1_handle_modifier(void *data,
|
||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf_v1, uint32_t format,
|
||||
uint32_t modifier_hi, uint32_t modifier_lo) {
|
||||
struct wlr_wl_backend *wl = data;
|
||||
|
||||
uint64_t modifier = ((uint64_t)modifier_hi << 32) | modifier_lo;
|
||||
wlr_drm_format_set_add(&wl->linux_dmabuf_v1_formats, format, modifier);
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_v1_listener linux_dmabuf_v1_listener = {
|
||||
.format = linux_dmabuf_v1_handle_format,
|
||||
.modifier = linux_dmabuf_v1_handle_modifier,
|
||||
};
|
||||
|
||||
static void registry_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *iface, uint32_t version) {
|
||||
struct wlr_wl_backend *wl = data;
|
||||
|
|
@ -85,6 +110,12 @@ static void registry_global(void *data, struct wl_registry *registry,
|
|||
} else if (strcmp(iface, zwp_tablet_manager_v2_interface.name) == 0) {
|
||||
wl->tablet_manager = wl_registry_bind(registry, name,
|
||||
&zwp_tablet_manager_v2_interface, 1);
|
||||
} else if (strcmp(iface, zwp_linux_dmabuf_v1_interface.name) == 0 &&
|
||||
version >= 3) {
|
||||
wl->zwp_linux_dmabuf_v1 = wl_registry_bind(registry, name,
|
||||
&zwp_linux_dmabuf_v1_interface, 3);
|
||||
zwp_linux_dmabuf_v1_add_listener(wl->zwp_linux_dmabuf_v1,
|
||||
&linux_dmabuf_v1_listener, wl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +184,8 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
wlr_renderer_destroy(wl->renderer);
|
||||
wlr_egl_finish(&wl->egl);
|
||||
|
||||
wlr_drm_format_set_finish(&wl->linux_dmabuf_v1_formats);
|
||||
|
||||
if (wl->pointer) {
|
||||
wl_pointer_destroy(wl->pointer);
|
||||
}
|
||||
|
|
@ -165,6 +198,9 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
if (wl->zwp_pointer_gestures_v1) {
|
||||
zwp_pointer_gestures_v1_destroy(wl->zwp_pointer_gestures_v1);
|
||||
}
|
||||
if (wl->zwp_linux_dmabuf_v1) {
|
||||
zwp_linux_dmabuf_v1_destroy(wl->zwp_linux_dmabuf_v1);
|
||||
}
|
||||
xdg_wm_base_destroy(wl->xdg_wm_base);
|
||||
wl_compositor_destroy(wl->compositor);
|
||||
wl_registry_destroy(wl->registry);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue