[PATCH xserver 1/2] xwayland: simplify xwl_glamor_pixmap_get_wl_buffer()

Olivier Fourdan ofourdan at redhat.com
Mon Jun 11 08:22:39 UTC 2018


When retrieving the Wayland buffer from a pixmap, if the buffer already
exists, the GBM backend will return that existing buffer.

However, as seen with the Present issues, if the call had previously
passed a wrong size, that buffer will remain at the wrong size for as
long as the buffer exists, which is error prone.

Considering that the width/height passed to get_wl_buffer() is always the
actual pixmap  drawable size, and considering that the EGLStream backend
makes no use of the size either, there is really no point in passing the
width/height around.

Simplify the xwl_glamor_pixmap_get_wl_buffer() and EGL backends API by
removing the pixmap size, and use the drawable size instead.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 hw/xwayland/xwayland-glamor-eglstream.c | 2 --
 hw/xwayland/xwayland-glamor-gbm.c       | 4 ++--
 hw/xwayland/xwayland-glamor.c           | 6 +-----
 hw/xwayland/xwayland-present.c          | 5 +----
 hw/xwayland/xwayland.c                  | 2 --
 hw/xwayland/xwayland.h                  | 4 ----
 6 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
index 43f34eed1..9950be94d 100644
--- a/hw/xwayland/xwayland-glamor-eglstream.c
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
@@ -308,8 +308,6 @@ xwl_glamor_eglstream_destroy_pixmap(PixmapPtr pixmap)
 
 static struct wl_buffer *
 xwl_glamor_eglstream_get_wl_buffer_for_pixmap(PixmapPtr pixmap,
-                                              unsigned short width,
-                                              unsigned short height,
                                               Bool *created)
 {
     /* XXX created? */
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index bb29cc28e..42d758e93 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -230,13 +230,13 @@ xwl_glamor_gbm_destroy_pixmap(PixmapPtr pixmap)
 
 static struct wl_buffer *
 xwl_glamor_gbm_get_wl_buffer_for_pixmap(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);
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+    unsigned short width = pixmap->drawable.width;
+    unsigned short height = pixmap->drawable.height;
     int prime_fd;
     int num_planes;
     uint32_t strides[4];
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 2f64d0500..61418e707 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -100,17 +100,13 @@ xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
 
 struct wl_buffer *
 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);
 
     if (xwl_screen->egl_backend->get_wl_buffer_for_pixmap)
         return xwl_screen->egl_backend->get_wl_buffer_for_pixmap(pixmap,
-                                                                width,
-                                                                height,
-                                                                created);
+                                                                 created);
 
     return NULL;
 }
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 29014a300..81e0eb9ce 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -456,10 +456,7 @@ xwl_present_flip(WindowPtr present_window,
 
     xwl_window->present_window = present_window;
 
-    buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
-                                             pixmap->drawable.width,
-                                             pixmap->drawable.height,
-                                             &buffer_created);
+    buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap, &buffer_created);
 
     event->event_id = event_id;
     event->xwl_present_window = xwl_present_window;
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 7ea01ab86..96b4db18c 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -678,8 +678,6 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 #ifdef XWL_HAS_GLAMOR
     if (xwl_screen->glamor)
         buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
-                                                 pixmap->drawable.width,
-                                                 pixmap->drawable.height,
                                                  NULL);
     else
 #endif
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 0fa5cb588..dc01c747c 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -96,8 +96,6 @@ struct xwl_egl_backend {
       * pixmap they've prepared beforehand.
       */
      struct wl_buffer *(*get_wl_buffer_for_pixmap)(PixmapPtr pixmap,
-                                                   unsigned short width,
-                                                   unsigned short height,
                                                    Bool *created);
 
      /* Called by Xwayland to perform any pre-wl_surface damage routines
@@ -439,8 +437,6 @@ Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
 Bool xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
                                      uint32_t id, uint32_t version);
 struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
-                                                  unsigned short width,
-                                                  unsigned short height,
                                                   Bool *created);
 void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  struct wl_registry *registry,
-- 
2.17.1



More information about the xorg-devel mailing list