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

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