[Mesa-dev] [PATCH] egl/android: Fix error condition for EGL_ANDROID_image_native_buffer

Pohjolainen, Topi topi.pohjolainen at intel.com
Tue May 7 00:49:50 PDT 2013


On Mon, May 06, 2013 at 02:23:52PM -0700, Chad Versace wrote:
> Emit EGL_BAD_CONTEXT if the user passes a context to
> eglCreateImageKHR(type=EGL_ANDROID_image_native_buffer).
> 
> From the EGL_ANDROID_image_native_buffer spec:
>   * If <target> is EGL_NATIVE_BUFFER_ANDROID and <ctx> is not
>     EGL_NO_CONTEXT, the error EGL_BAD_CONTEXT is generated.
> 
> Note: This is a candidate for the stable branches.
> CC: Tapani Pälli <tapani.palli at intel.com>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  src/egl/drivers/dri2/platform_android.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index cee4035..ed50907 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -337,7 +337,7 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
>  }
>  
>  static _EGLImage *
> -dri2_create_image_android_native_buffer(_EGLDisplay *disp,
> +dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
>                                          struct ANativeWindowBuffer *buf)
>  {
>     struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> @@ -346,6 +346,18 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
>     uint32_t offsets[3], strides[3], handles[3], tmp;
>     EGLint format;
>  
> +   if (ctx != NULL) {

I did a similar check for the 'EGL_LINUX_DMA_BUF_EXT'. Technically
'eglapi.c::eglCreateImageKhr()' does a lookup of the context via
'_eglLookupContext()' and does a "translation" of 'EGL_NO_CONTEXT' also (from
NULL to NULL). Hence I chose to do the check there. But would it be better for
me to do it also in the driver side as the target is valid only for linux
platforms anyway?

> +      /* From the EGL_ANDROID_image_native_buffer spec:
> +       *
> +       *     * If <target> is EGL_NATIVE_BUFFER_ANDROID and <ctx> is not
> +       *       EGL_NO_CONTEXT, the error EGL_BAD_CONTEXT is generated.
> +       */
> +      _eglError(EGL_BAD_CONTEXT, "eglCreateEGLImageKHR: for "
> +                "EGL_NATIVE_BUFFER_ANDROID, the context must be "
> +                "EGL_NO_CONTEXT");
> +      return NULL;
> +   }
> +
>     if (!buf || buf->common.magic != ANDROID_NATIVE_BUFFER_MAGIC ||
>         buf->common.version != sizeof(*buf)) {
>        _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> @@ -479,7 +491,7 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
>  {
>     switch (target) {
>     case EGL_NATIVE_BUFFER_ANDROID:
> -      return dri2_create_image_android_native_buffer(disp,
> +      return dri2_create_image_android_native_buffer(disp, ctx,
>              (struct ANativeWindowBuffer *) buffer);
>     default:
>        return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list);
> -- 
> 1.8.1.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list