Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8cbc20d authored by Tatenda Chipeperekwa's avatar Tatenda Chipeperekwa Committed by Linux Build Service Account
Browse files

Do not limit android EGL wrapper to RGB formats.

Implementation may support other color buffer type than RGB and luminance, in
that case allow client to choose implementation supported formats

Change-Id: Ibb187e8849a41b5e60e86a33ddfba77f6b47f848
parent ed80af42
Loading
Loading
Loading
Loading
+44 −30
Original line number Diff line number Diff line
@@ -453,12 +453,25 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
#else
        // by default, just pick RGBA_8888
        EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
        EGLint color_buffer = EGL_RGB_BUFFER;

        if (!cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_COLOR_BUFFER_TYPE, &color_buffer))
        {
            ALOGE("Could not configure a color buffer format");
            return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
        }
        if (EGL_RGB_BUFFER != color_buffer &&
            EGL_LUMINANCE_BUFFER != color_buffer)
        {
            cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_NATIVE_VISUAL_ID, &format);
        }
        else
        {
            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;
                // Format will already be RGBA8888
            } else {
                EGLint r, g, b;
                r = g = b = 0;
@@ -491,6 +504,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
                    }
                }
            }
        }
#endif
        if (format != 0) {
            int err = native_window_set_buffers_format(window, format);