OSDN Git Service

libEGL: select pixel format by EGL_NATIVE_VISUAL_ID
authorChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 23 Nov 2015 17:08:11 +0000 (01:08 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 5 May 2016 17:57:58 +0000 (01:57 +0800)
We need this workaround until Mesa supports HAL_PIXEL_FORMAT_RGBA_8888.

opengl/libs/EGL/eglApi.cpp

index fc71662..a86c54c 100644 (file)
@@ -496,15 +496,19 @@ EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
         // modify the EGLconfig's format before setting the native window's
         // format.
 
-        // by default, just pick RGBA_8888
-        EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
+        EGLint format;
         android_dataspace dataSpace = HAL_DATASPACE_UNKNOWN;
 
         EGLint a = 0;
         cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a);
         if (a > 0) {
             // alpha-channel requested, there's really only one suitable format
-            format = HAL_PIXEL_FORMAT_RGBA_8888;
+            if (!cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_NATIVE_VISUAL_ID,
+                    &format)) {
+                ALOGE("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID) failed: %#x",
+                        eglGetError());
+                format = HAL_PIXEL_FORMAT_RGBA_8888;
+            }
         } else {
             EGLint r, g, b;
             r = g = b = 0;