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

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