blob: 4827e2837756bb71942dac46797b5b60deec529c [file] [log] [blame]
From 240bfe45d9bf83b326aee526c1fa3cc62c49c43b Mon Sep 17 00:00:00 2001
From: Lepton Wu <lepton@chromium.org>
Date: Thu, 12 Sep 2019 06:38:59 +0000
Subject: [PATCH] egl/android: Only keep BGRA EGL configs as fallback
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Stock Android code actually doesn't support BGRA format EGL
configs. It's hard coded to use RGBA_8888 as window format
for BGRA EGL configs here:
https://android.googlesource.com/platform/frameworks/native/+/1eb32e2/opengl/libs/EGL/eglApi.cpp#608
So just remove it from EGL configs if RGBA is supported.
Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Tapani Pรคlli <tapani.palli@intel.com>
---
src/egl/drivers/dri2/platform_android.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index f35e4155892..d26575e0f10 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1131,6 +1131,9 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
{ HAL_PIXEL_FORMAT_RGBA_8888, { 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 } },
{ HAL_PIXEL_FORMAT_RGBX_8888, { 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 } },
{ HAL_PIXEL_FORMAT_RGB_565, { 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 } },
+ /* This must be after HAL_PIXEL_FORMAT_RGBA_8888, we only keep BGRA
+ * visual if it turns out RGBA visual is not available.
+ */
{ HAL_PIXEL_FORMAT_BGRA_8888, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } },
};
@@ -1155,7 +1158,13 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
* (chadversary) testing on Android Nougat, this was good enough to pacify
* the buggy clients.
*/
+ bool has_rgba = false;
for (int i = 0; i < ARRAY_SIZE(visuals); i++) {
+ /* Only enable BGRA configs when RGBA is not available. BGRA configs are
+ * buggy on stock Android.
+ */
+ if (visuals[i].format == HAL_PIXEL_FORMAT_BGRA_8888 && has_rgba)
+ continue;
for (int j = 0; dri2_dpy->driver_configs[j]; j++) {
const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
@@ -1177,6 +1186,8 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
format_count[i]++;
}
}
+ if (visuals[i].format == HAL_PIXEL_FORMAT_RGBA_8888 && format_count[i])
+ has_rgba = true;
}
for (int i = 0; i < ARRAY_SIZE(format_count); i++) {
--
2.23.0.237.gc6a4ce50a0-goog