[Mesa-dev] [RFC v5 01/19] dri: fromPlanar() can return NULL as a valid result

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Mon Nov 6 22:02:31 UTC 2017


It was assumed that fromPlanar() could return NULL to mean
that the planar image is the same as the parent DRI image.
That assumption wasn't made everywhere though.

Let's fix things and make sure that all callers understand
a NULL result

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
 src/egl/drivers/dri2/platform_wayland.c | 9 +++------
 src/gbm/backends/dri/gbm_dri.c          | 1 +
 src/loader/loader_dri3_helper.c         | 5 ++++-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index b38eb1c335..fbfab5f106 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -725,13 +725,10 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
          int stride, offset;
          int fd = -1;
 
-         if (i == 0)
-            p_image = image;
-         else
-            p_image = dri2_dpy->image->fromPlanar(image, i, NULL);
+         p_image = dri2_dpy->image->fromPlanar(image, i, NULL);
          if (!p_image) {
-            zwp_linux_buffer_params_v1_destroy(params);
-            return NULL;
+            assert(plane == 0);
+            p_image = image;
          }
 
          query = dri2_dpy->image->queryImage(p_image,
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 0a4853bf63..e057a360e9 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -825,6 +825,7 @@ gbm_dri_bo_get_offset(struct gbm_bo *_bo, int plane)
       dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_OFFSET, &offset);
       dri->image->destroyImage(image);
    } else {
+      assert(plane == 0);
       dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_OFFSET, &offset);
    }
 
diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 19ab581510..372a6e943a 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -1245,7 +1245,10 @@ loader_dri3_create_image(xcb_connection_t *c,
 
    ret = image->fromPlanar(image_planar, 0, loaderPrivate);
 
-   image->destroyImage(image_planar);
+   if (!ret)
+      ret = image_planar;
+   else
+      image->destroyImage(image_planar);
 
    return ret;
 }
-- 
2.13.0



More information about the mesa-dev mailing list