[PATCH 18/19] xwayland: Add arguments to glamor_pixmap_get_wl_buffer

Roman Gilg subdiff at gmail.com
Mon Jan 29 13:34:16 UTC 2018


Add arguments to allow 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 | 22 ++++++++++++++++++----
 hw/xwayland/xwayland.c        |  5 ++++-
 hw/xwayland/xwayland.h        |  5 ++++-
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 8ffb40d..cfc6dc3 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -153,14 +153,28 @@ 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, also
+        // inform caller if interested
+        if(created)
+            *created = FALSE;
         return xwl_pixmap->buffer;
+    }
+
+    // buffer does not yet exist
+    // and will be created now,
+    // inform caller if interested
+    if(created)
+        *created = TRUE;
 
     prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
     if (prime_fd == -1)
@@ -168,8 +182,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 19aa14a..2191956 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -642,7 +642,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