xwayland: Add xwl_pixmap_get_wl_buffer helper

Preparation for the next commit.
This commit is contained in:
Michel Dänzer 2024-01-18 17:10:57 +01:00 committed by Michel Dänzer
parent 613e4466b4
commit 17986658bf
3 changed files with 21 additions and 7 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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");