[Mesa-dev] [PATCH v2] From: Emil Velikov <emil.velikov at collabora.com>
Emil Velikov
emil.l.velikov at gmail.com
Mon Aug 21 14:08:49 UTC 2017
As said in the EGL_KHR_platform_android extensions
For each EGLConfig that belongs to the Android platform, the
EGL_NATIVE_VISUAL_ID attribute is an Android window format, such as
WINDOW_FORMAT_RGBA_8888.
Although it should be applicable overall.
Even though we use HAL_PIXEL_FORMAT here, those are numerically
identical to the WINDOW_FORMAT_ and AHARDWAREBUFFER_FORMAT_ ones.
Barring HAL_PIXEL_FORMAT_BGRA_8888 which does not have an equivalent.
Keep in mind that even if we try to use the said format, you'll get
caught by droid_create_surface(). The function compares the format of
the underlying window, against the NATIVE_VISUAL_ID of the config.
Unfortunately it only prints a warning, rather than error out, likely
leading to visual corruption.
Users can call ANativeWindow_setBuffersGeometry() with the wrong format,
and in the case of SDL ignore the [expected] failure.
v2: Keep the format in the EGL image path. The camera uses it on some
platforms (Tomasz Figa).
Cc: mesa-stable at lists.freedesktop.org
Cc: Chad Versace <chadversary at google.com>
Cc: Tomasz Figa <tfiga at chromium.org>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/egl/drivers/dri2/platform_android.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index beb474025f7..8778a118ac2 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1036,8 +1036,15 @@ 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 } },
- { HAL_PIXEL_FORMAT_BGRA_8888, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } },
};
+ /* Do not expose visuals with HAL_PIXEL_FORMAT_BGRA_8888 format.
+ *
+ * The formats exposed must align with the WINDOW_FORMAT_ enum, which is
+ * missing instance for BGRA8888.
+ *
+ * At the same time, the format is allowed when EGL image is created as
+ * it is used by camera et al. - as mentioned by Tomasz Figa.
+ */
unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
int config_count = 0;
--
2.14.0
More information about the mesa-dev
mailing list