[Commits] SDL: EGL: Request sRGB framebuffer in correct place.

libsdl.org revision control commits-owner at libsdl.org
Wed Jan 17 13:09:50 PST 2018


details:   https://hg.libsdl.org/SDL/rev/a01af1a724b3
changeset: 11830:a01af1a724b3
user:      Dawid Gan <deveee at gmail.com>
date:      Tue Jan 16 21:29:32 2018 +0100
description:
EGL: Request sRGB framebuffer in correct place.

The EGL_GL_COLORSPACE_KHR is an attribute for eglCreate*Surface.

As written in EGL_KHR_gl_colorspace documentation:

    Accepted as an attribute name by eglCreateWindowSurface,
    eglCreatePbufferSurface and eglCreatePixmapSurface

        EGL_GL_COLORSPACE_KHR                   0x309D
    (...)

diffstat:

 src/video/SDL_egl.c |  32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diffs (60 lines):

diff -r fcbafc9e443c -r a01af1a724b3 src/video/SDL_egl.c
--- a/src/video/SDL_egl.c	Wed Jan 17 13:17:10 2018 -0800
+++ b/src/video/SDL_egl.c	Tue Jan 16 21:29:32 2018 +0100
@@ -519,18 +519,6 @@
         attribs[i++] = _this->gl_config.multisamplesamples;
     }
 
-    if (_this->gl_config.framebuffer_srgb_capable) {
-#ifdef EGL_KHR_gl_colorspace
-        if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
-            attribs[i++] = EGL_GL_COLORSPACE_KHR;
-            attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
-        } else
-#endif
-        {
-            return SDL_SetError("EGL implementation does not support sRGB system framebuffers");
-        }
-    }
-
     attribs[i++] = EGL_RENDERABLE_TYPE;
     if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
 #ifdef EGL_KHR_create_context
@@ -799,6 +787,10 @@
 EGLSurface *
 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) 
 {
+    /* max 2 values plus terminator. */
+    EGLint attribs[3];
+    int attr = 0;
+	
     EGLSurface * surface;
 
     if (SDL_EGL_ChooseConfig(_this) != 0) {
@@ -818,11 +810,25 @@
         ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
     }
 #endif    
+    if (_this->gl_config.framebuffer_srgb_capable) {
+#ifdef EGL_KHR_gl_colorspace
+        if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
+            attribs[attr++] = EGL_GL_COLORSPACE_KHR;
+            attribs[attr++] = EGL_GL_COLORSPACE_SRGB_KHR;
+        } else
+#endif
+        {
+            SDL_SetError("EGL implementation does not support sRGB system framebuffers");
+            return EGL_NO_SURFACE;
+        }
+    }
+	
+    attribs[attr++] = EGL_NONE;
     
     surface = _this->egl_data->eglCreateWindowSurface(
             _this->egl_data->egl_display,
             _this->egl_data->egl_config,
-            nw, NULL);
+            nw, &attribs[0]);
     if (surface == EGL_NO_SURFACE) {
         SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
     }


More information about the commits mailing list