From 17986658bf90ae0f999d5823dec61245c300dd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 18 Jan 2024 17:10:57 +0100 Subject: [PATCH] xwayland: Add xwl_pixmap_get_wl_buffer helper Preparation for the next commit. --- hw/xwayland/xwayland-pixmap.c | 18 ++++++++++++++++++ hw/xwayland/xwayland-pixmap.h | 1 + hw/xwayland/xwayland-window.c | 9 ++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/xwayland/xwayland-pixmap.c b/hw/xwayland/xwayland-pixmap.c index 6e797a34c..8e929f029 100644 --- a/hw/xwayland/xwayland-pixmap.c +++ b/hw/xwayland/xwayland-pixmap.c @@ -33,8 +33,13 @@ #include "fb.h" #include "pixmapstr.h" +#ifdef XWL_HAS_GLAMOR +#include "xwayland-glamor.h" +#endif #include "xwayland-types.h" #include "xwayland-pixmap.h" +#include "xwayland-screen.h" +#include "xwayland-shm.h" #include "xwayland-window-buffers.h" static DevPrivateKeyRec xwl_pixmap_private_key; @@ -57,6 +62,19 @@ xwl_pixmap_get(PixmapPtr pixmap) return dixLookupPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key); } +struct wl_buffer * +xwl_pixmap_get_wl_buffer(PixmapPtr pixmap) +{ +#ifdef XWL_HAS_GLAMOR + struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); + + if (xwl_screen->glamor) + return xwl_glamor_pixmap_get_wl_buffer(pixmap); + else +#endif + return xwl_shm_pixmap_get_wl_buffer(pixmap); +} + Bool xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, xwl_buffer_release_cb func, void *data) diff --git a/hw/xwayland/xwayland-pixmap.h b/hw/xwayland/xwayland-pixmap.h index 06ee4898a..95eb4e1a2 100644 --- a/hw/xwayland/xwayland-pixmap.h +++ b/hw/xwayland/xwayland-pixmap.h @@ -38,6 +38,7 @@ typedef void (*xwl_buffer_release_cb) (void *data); void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap); struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap); +struct wl_buffer *xwl_pixmap_get_wl_buffer(PixmapPtr pixmap); Bool xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, xwl_buffer_release_cb func, void *data); void xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap); diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index aaeeace68..41dc1663e 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -39,6 +39,7 @@ #include "xwayland-types.h" #include "xwayland-input.h" +#include "xwayland-pixmap.h" #include "xwayland-present.h" #include "xwayland-screen.h" #include "xwayland-window.h" @@ -1394,13 +1395,7 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window) region = DamageRegion(window_get_damage(xwl_window->window)); pixmap = xwl_window_buffers_get_pixmap(xwl_window, region); - -#ifdef XWL_HAS_GLAMOR - if (xwl_screen->glamor) - buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap); - else -#endif - buffer = xwl_shm_pixmap_get_wl_buffer(pixmap); + buffer = xwl_pixmap_get_wl_buffer(pixmap); if (!buffer) { ErrorF("Error getting buffer\n");