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