Blame SOURCES/0018-xwayland-eglstream-Check-eglSwapBuffers.patch

4c4b8b
From a964ccdadf351d90482df00c272dee3634f7a8ee Mon Sep 17 00:00:00 2001
4c4b8b
From: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Date: Fri, 30 Apr 2021 09:02:29 +0200
4c4b8b
Subject: [PATCH xserver 18/27] xwayland/eglstream: Check eglSwapBuffers()
4c4b8b
MIME-Version: 1.0
4c4b8b
Content-Type: text/plain; charset=UTF-8
4c4b8b
Content-Transfer-Encoding: 8bit
4c4b8b
4c4b8b
EGLstream's post_damage() would unconditionally return success
4c4b8b
regardless of the actual status of the eglSwapBuffers().
4c4b8b
4c4b8b
Yet, if eglSwapBuffers() fails, we should not post the corresponding
4c4b8b
damage as they wouldn't match the actual content of the buffer.
4c4b8b
4c4b8b
Use the eglSwapBuffers() return value as the return value for
4c4b8b
post_damage() and do not take a refrence on the pixmap if it fails.
4c4b8b
4c4b8b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
4c4b8b
(cherry picked from commit b583395cd38ad101c7541bd8b0e91143ced44703)
4c4b8b
---
4c4b8b
 hw/xwayland/xwayland-glamor-eglstream.c | 14 ++++++++++----
4c4b8b
 1 file changed, 10 insertions(+), 4 deletions(-)
4c4b8b
4c4b8b
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
index 3a3caa976..6721acfe8 100644
4c4b8b
--- a/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
@@ -750,14 +750,20 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
4c4b8b
     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
4c4b8b
 
4c4b8b
     if (xwl_eglstream->have_egl_damage)
4c4b8b
-        eglSwapBuffersWithDamageKHR(xwl_screen->egl_display,
4c4b8b
-                                    xwl_pixmap->surface, egl_damage, 1);
4c4b8b
+        status = eglSwapBuffersWithDamageKHR(xwl_screen->egl_display,
4c4b8b
+                                             xwl_pixmap->surface,
4c4b8b
+                                             egl_damage, 1);
4c4b8b
     else
4c4b8b
-        eglSwapBuffers(xwl_screen->egl_display, xwl_pixmap->surface);
4c4b8b
+        status = eglSwapBuffers(xwl_screen->egl_display,
4c4b8b
+                                xwl_pixmap->surface);
4c4b8b
+
4c4b8b
+    if (!status) {
4c4b8b
+        ErrorF("eglstream: buffer swap failed, not posting damage\n");
4c4b8b
+        goto out;
4c4b8b
+    }
4c4b8b
 
4c4b8b
     /* hang onto the pixmap until the compositor has released it */
4c4b8b
     pixmap->refcnt++;
4c4b8b
-    status = TRUE;
4c4b8b
 
4c4b8b
 out:
4c4b8b
     /* Restore previous state */
4c4b8b
-- 
4c4b8b
2.31.1
4c4b8b