[Mesa-dev] [PATCH 08/10] egl/android: Make get_fourcc() accept HAL formats

Emil Velikov emil.l.velikov at gmail.com
Mon Jul 18 10:33:56 UTC 2016


On 15 July 2016 at 08:53, Tomasz Figa <tfiga at chromium.org> wrote:
> 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 <tfiga at chromium.org>
> ---
>  src/egl/drivers/dri2/platform_android.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 4473400..26d7b35 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -69,18 +69,20 @@ 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;

Is there a complete documentation about the HAL formats ? A one which
mentions endianess, channel encoding (packed vs array vs other), i.e.
something like the following two in mesa

src/mesa/main/formats.csv
src/gallium/auxiliary/util/u_format.csv

> +   default:
> +      _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", native);
>     }
>     return -1;
>  }
>
> +#ifdef HAS_GRALLOC_DRM_HEADERS
We should be able to drop this with the previous local header
suggestion. Afaict the compiler/optimiser should be smart enough to
discard it for us without the annoying warning message.

Thanks
Emil


More information about the mesa-dev mailing list