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

2018-06-11 Thread Michel Dänzer
On 2018-06-11 10:22 AM, Olivier Fourdan wrote:
> 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 

Reviewed-by: Michel Dänzer 

Since the Wayland buffer represents the pixmap, their dimensions must
always match.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

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

2018-06-11 Thread Olivier Fourdan
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 
---
 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,
- _created);
+buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap, _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