aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorTomasz Figa <[email protected]>2016-08-02 20:07:53 +0900
committerChad Versace <[email protected]>2016-08-08 11:40:41 -0700
commit7dfb1a4074328bcdff4b407b8f44be538180791d (patch)
tree89d2383e76524208582d095b20c138b90afa6990 /src/egl/drivers
parente77b4933907106238c7872cb74d0ba0b5246aee6 (diff)
egl/android: Make get_fourcc() accept HAL formats
There are DRI_IMAGE_FOURCC macros, for which there are no corresponding DRI_IMAGE_FORMAT macros. To support such formats we need to make the lookup function take the native format directly. As a side effect, it simplifies all existing calls to this function, because they all called get_format() first to convert from native to DRI_IMAGE_FORMAT. Signed-off-by: Tomasz Figa <[email protected]> Tested-by: Rob Herring <[email protected]> Reviewed-by: Chad Versace <[email protected]> Change-Id: I4674000fb5ccfd02e38b8fa89bc567ac1d4fc16b
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/platform_android.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 94e765d7d8b..596833e8501 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -66,14 +66,15 @@ get_format_bpp(int native)
}
/* createImageFromFds requires fourcc format */
-static int get_fourcc(int format)
+static int get_fourcc(int native)
{
- switch(format) {
- case __DRI_IMAGE_FORMAT_RGB565: return __DRI_IMAGE_FOURCC_RGB565;
- case __DRI_IMAGE_FORMAT_ARGB8888: return __DRI_IMAGE_FOURCC_ARGB8888;
- case __DRI_IMAGE_FORMAT_XRGB8888: return __DRI_IMAGE_FOURCC_XRGB8888;
- case __DRI_IMAGE_FORMAT_ABGR8888: return __DRI_IMAGE_FOURCC_ABGR8888;
- case __DRI_IMAGE_FORMAT_XBGR8888: return __DRI_IMAGE_FOURCC_XBGR8888;
+ switch (native) {
+ case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FOURCC_RGB565;
+ case HAL_PIXEL_FORMAT_BGRA_8888: return __DRI_IMAGE_FOURCC_ARGB8888;
+ case HAL_PIXEL_FORMAT_RGBA_8888: return __DRI_IMAGE_FOURCC_ABGR8888;
+ case HAL_PIXEL_FORMAT_RGBX_8888: return __DRI_IMAGE_FOURCC_XBGR8888;
+ default:
+ _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", native);
}
return -1;
}
@@ -92,6 +93,7 @@ static int get_format(int format)
}
return -1;
}
+
static int
get_native_buffer_fd(struct ANativeWindowBuffer *buf)
{
@@ -397,7 +399,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
return -1;
}
- fourcc = get_fourcc(get_format(dri2_surf->buffer->format));
+ fourcc = get_fourcc(dri2_surf->buffer->format);
pitch = dri2_surf->buffer->stride *
get_format_bpp(dri2_surf->buffer->format);
@@ -481,7 +483,7 @@ static _EGLImage *
droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
struct ANativeWindowBuffer *buf, int fd)
{
- const int fourcc = get_fourcc(get_format(buf->format));
+ const int fourcc = get_fourcc(buf->format);
const int pitch = buf->stride * get_format_bpp(buf->format);
const EGLint attr_list[14] = {