[Mesa-dev] [PATCH v2 2/4] egl: android: factor out format conversion code to a function

Emil Velikov emil.l.velikov at gmail.com
Fri Apr 29 11:24:57 UTC 2016


On 28 April 2016 at 21:37, Rob Herring <robh at kernel.org> wrote:
> Signed-off-by: Rob Herring <robh at kernel.org>
> ---
>  src/egl/drivers/dri2/platform_android.c | 38 +++++++++++++--------------------
>  1 file changed, 15 insertions(+), 23 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 02122e3..204931b 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -65,6 +65,20 @@ get_format_bpp(int native)
>     return bpp;
>  }
>
> +static int get_format(int format)
> +{
> +   switch (format) {
> +   case HAL_PIXEL_FORMAT_BGRA_8888: return __DRI_IMAGE_FORMAT_ARGB8888;
> +   case HAL_PIXEL_FORMAT_RGB_565:   return __DRI_IMAGE_FORMAT_RGB565;
> +   case HAL_PIXEL_FORMAT_RGBA_8888: return __DRI_IMAGE_FORMAT_ABGR8888;
> +   case HAL_PIXEL_FORMAT_RGBX_8888: return __DRI_IMAGE_FORMAT_XBGR8888;
> +   case HAL_PIXEL_FORMAT_RGB_888:
> +      /* unsupported */
> +   default:
> +      _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", format);
> +   }
> +   return -1;
> +}
>  static int
>  get_native_buffer_name(struct ANativeWindowBuffer *buf)
>  {
> @@ -332,7 +346,6 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
>     struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>     struct dri2_egl_image *dri2_img;
>     int name;
> -   EGLint format;
>
>     if (ctx != NULL) {
>        /* From the EGL_ANDROID_image_native_buffer spec:
> @@ -358,27 +371,6 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
>        return NULL;
>     }
>
> -   /* see the table in droid_add_configs_for_visuals */
> -   switch (buf->format) {
> -   case HAL_PIXEL_FORMAT_BGRA_8888:
> -      format = __DRI_IMAGE_FORMAT_ARGB8888;
> -      break;
> -   case HAL_PIXEL_FORMAT_RGB_565:
> -      format = __DRI_IMAGE_FORMAT_RGB565;
> -      break;
> -   case HAL_PIXEL_FORMAT_RGBA_8888:
> -      format = __DRI_IMAGE_FORMAT_ABGR8888;
> -      break;
> -   case HAL_PIXEL_FORMAT_RGBX_8888:
> -      format = __DRI_IMAGE_FORMAT_XBGR8888;
> -      break;
> -   case HAL_PIXEL_FORMAT_RGB_888:
> -      /* unsupported */
> -   default:
> -      _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", buf->format);
> -      return NULL;
> -      break;
> -   }
>
Unless you insist I'll keep (will amend before pushing) the preemptive
format check here, as opposed to feeding -1 into
createImageFromName(). On the gallium side things look ok, although
I'm not sure if others won't explode.

Thanks
Emil


More information about the mesa-dev mailing list