Mesa (master): egl/android: Simplify droid_create_image_from_name() path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 18 17:38:58 UTC 2020


Module: Mesa
Branch: master
Commit: 5c8b67ed0c4f0d54755aff2f247d4e7e6fd76af9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c8b67ed0c4f0d54755aff2f247d4e7e6fd76af9

Author: Kristian H. Kristensen <hoegsberg at google.com>
Date:   Thu Aug  6 17:39:47 2020 -0700

egl/android: Simplify droid_create_image_from_name() path

This can now return an __DRIimage which we'll wrap in the shared code
in dri2_create_image_android_native_buffer().

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6055>

---

 src/egl/drivers/dri2/platform_android.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index f12ac4f6302..dad942abb72 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -941,7 +941,7 @@ droid_create_image_from_name(_EGLDisplay *disp,
                              struct ANativeWindowBuffer *buf)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   struct dri2_egl_image *dri2_img;
+   __DRIimage *dri_image;
    int name;
    int format;
 
@@ -955,15 +955,7 @@ droid_create_image_from_name(_EGLDisplay *disp,
    if (format == -1)
        return NULL;
 
-   dri2_img = calloc(1, sizeof(*dri2_img));
-   if (!dri2_img) {
-      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
-      return NULL;
-   }
-
-   _eglInitImage(&dri2_img->base, disp);
-
-   dri2_img->dri_image =
+   return
       dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
 					   buf->width,
 					   buf->height,
@@ -971,13 +963,6 @@ droid_create_image_from_name(_EGLDisplay *disp,
 					   name,
 					   buf->stride,
 					   dri2_img);
-   if (!dri2_img->dri_image) {
-      free(dri2_img);
-      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
-      return NULL;
-   }
-
-   return &dri2_img->base;
 }
 #endif /* HAVE_DRM_GRALLOC */
 
@@ -1032,14 +1017,16 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
 
    __DRIimage *dri_image =
       droid_create_image_from_prime_fds(disp, buf);
+
+#ifdef HAVE_DRM_GRALLOC
+   if (dri_image == NULL)
+      dri_image = droid_create_image_from_name(disp, buf);
+#endif
+
    if (dri_image)
       return dri2_create_image_from_dri(disp, dri_image);
 
-#ifdef HAVE_DRM_GRALLOC
-   return droid_create_image_from_name(disp, buf);
-#else
    return NULL;
-#endif
 }
 
 static _EGLImage *



More information about the mesa-commit mailing list