Commit 5113fedfa0e8592048a66cf8f852a59441e8bc9c

Eric Engestrom 2021-08-02T23:01:12

video/wayland: use EGL_EXT_present_opaque when available

diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 87d693e..41966db 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -43,6 +43,11 @@
 #endif
 #endif /* EGL_KHR_create_context */
 
+#ifndef EGL_EXT_present_opaque
+#define EGL_EXT_present_opaque 1
+#define EGL_PRESENT_OPAQUE_EXT            0x31DF
+#endif /* EGL_EXT_present_opaque */
+
 #if SDL_VIDEO_DRIVER_RPI
 /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
 #define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "libbrcmEGL.so" )
@@ -1182,8 +1187,8 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
     EGLint format_wanted;
     EGLint format_got;
 #endif
-    /* max 2 values plus terminator. */
-    EGLint attribs[3];
+    /* max 2 key+value pairs, plus terminator. */
+    EGLint attribs[5];
     int attr = 0;
 
     EGLSurface * surface;
@@ -1216,6 +1221,13 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
         }
     }
 
+#ifdef EGL_EXT_present_opaque
+    if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) {
+        attribs[attr++] = EGL_PRESENT_OPAQUE_EXT;
+        attribs[attr++] = EGL_TRUE;
+    }
+#endif
+
     attribs[attr++] = EGL_NONE;
     
     surface = _this->egl_data->eglCreateWindowSurface(