summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 011dddfabf4..04c04cc304c 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -678,23 +678,37 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
__DRIimage *image)
{
struct wl_buffer *ret;
+ EGLBoolean query;
int width, height, fourcc, num_planes;
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width);
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, &height);
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FOURCC, &fourcc);
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES,
- &num_planes);
+ query = dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width);
+ query &= dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT,
+ &height);
+ query &= dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FOURCC,
+ &fourcc);
+ if (!query)
+ return NULL;
+
+ query = dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES,
+ &num_planes);
+ if (!query)
+ num_planes = 1;
if (dri2_dpy->wl_dmabuf && dri2_dpy->image->base.version >= 15) {
struct zwp_linux_buffer_params_v1 *params;
int mod_hi, mod_lo;
int i;
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER,
- &mod_hi);
- dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_LOWER,
- &mod_lo);
+ query = dri2_dpy->image->queryImage(image,
+ __DRI_IMAGE_ATTRIB_MODIFIER_UPPER,
+ &mod_hi);
+ query &= dri2_dpy->image->queryImage(image,
+ __DRI_IMAGE_ATTRIB_MODIFIER_LOWER,
+ &mod_lo);
+ if (!query) {
+ mod_hi = DRM_FORMAT_MOD_INVALID >> 32;
+ mod_lo = DRM_FORMAT_MOD_INVALID & 0xffffffff;
+ }
/* We don't need a wrapper for wl_dmabuf objects, because we have to
* create the intermediate params object; we can set the queue on this,
@@ -705,7 +719,8 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
for (i = 0; i < num_planes; i++) {
__DRIimage *p_image;
- int stride, offset, fd;
+ int stride, offset;
+ int fd = -1;
if (i == 0)
p_image = image;
@@ -716,14 +731,25 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
return NULL;
}
- dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_FD, &fd);
- dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_STRIDE,
- &stride);
- dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_OFFSET,
- &offset);
+ query = dri2_dpy->image->queryImage(p_image,
+ __DRI_IMAGE_ATTRIB_FD,
+ &fd);
+ query &= dri2_dpy->image->queryImage(p_image,
+ __DRI_IMAGE_ATTRIB_STRIDE,
+ &stride);
+ query &= dri2_dpy->image->queryImage(p_image,
+ __DRI_IMAGE_ATTRIB_OFFSET,
+ &offset);
if (image != p_image)
dri2_dpy->image->destroyImage(p_image);
+ if (!query) {
+ if (fd >= 0)
+ close(fd);
+ zwp_linux_buffer_params_v1_destroy(params);
+ return NULL;
+ }
+
zwp_linux_buffer_params_v1_add(params, fd, i, offset, stride,
mod_hi, mod_lo);
close(fd);