[PATCH xserver v2 18/22] xwayland: Add arguments to glamor_pixmap_get_wl_buffer

Roman Gilg subdiff at gmail.com
Wed Feb 28 16:37:00 UTC 2018


Add arguments to give the caller more information and control
over the creation of a wl_buffer with GBM, in particular let
the caller determine the size of the buffer.

Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
 hw/xwayland/xwayland-glamor.c | 19 +++++++++++++++----
 hw/xwayland/xwayland.c        |  5 ++++-
 hw/xwayland/xwayland.h        |  5 ++++-
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 8ffb40d..ee7e11c 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -153,14 +153,25 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, int depth)
 }
 
 struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+                                unsigned short width,
+                                unsigned short height,
+                                Bool *created)
 {
     struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
     struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
     int prime_fd;
 
-    if (xwl_pixmap->buffer)
+    if (xwl_pixmap->buffer) {
+        /* Buffer already exists. Return it and inform caller if interested. */
+        if (created)
+            *created = FALSE;
         return xwl_pixmap->buffer;
+    }
+
+    /* Buffer does not exist yet. Create now and inform caller if interested. */
+    if (created)
+        *created = TRUE;
 
     prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
     if (prime_fd == -1)
@@ -168,8 +179,8 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 
     xwl_pixmap->buffer =
         wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
-                                   pixmap->drawable.width,
-                                   pixmap->drawable.height,
+                                   width,
+                                   height,
                                    drm_format_for_depth(pixmap->drawable.depth),
                                    0, gbm_bo_get_stride(xwl_pixmap->bo),
                                    0, 0,
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 73bc47a..8c1111b 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -649,7 +649,10 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
 #ifdef GLAMOR_HAS_GBM
     if (xwl_screen->glamor)
-        buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+        buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
+                                                 pixmap->drawable.width,
+                                                 pixmap->drawable.height,
+                                                 NULL);
     else
 #endif
         buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index ffa0d72..783ab59 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -328,7 +328,10 @@ Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
 
 Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
                          uint32_t id, uint32_t version);
-struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
+struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+                                                  unsigned short width,
+                                                  unsigned short height,
+                                                  Bool *created);
 
 void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
 
-- 
2.7.4



More information about the xorg-devel mailing list