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

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