* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 1
+#define __DRI_IMAGE_VERSION 2
/**
* These formats correspond to the similarly named MESA_FORMAT_*
* The new __DRIimage will share the content with the old one, see dup(2).
*/
__DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
+
+ /**
+ * Validate that a __DRIimage can be used a certain way.
+ *
+ * \since 2
+ */
+ GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
};
}
static struct __DRIimageExtensionRec dri2ImageExtension = {
- { __DRI_IMAGE, __DRI_IMAGE_VERSION },
+ { __DRI_IMAGE, 1 },
dri2_create_image_from_name,
dri2_create_image_from_renderbuffer,
dri2_destroy_image,
{
struct gbm_dri_device *dri = gbm_dri_device(gbm);
struct gbm_dri_bo *bo;
+ unsigned dri_use = 0;
(void) egl_dpy;
if (bo->image == NULL)
return NULL;
+ if (usage & GBM_BO_USE_SCANOUT)
+ dri_use |= __DRI_IMAGE_USE_SCANOUT;
+ if (usage & GBM_BO_USE_CURSOR_64X64)
+ dri_use |= __DRI_IMAGE_USE_CURSOR;
+ if (dri->image->base.version >= 2 &&
+ !dri->image->validateUsage(bo->image, dri_use)) {
+ free(bo);
+ return NULL;
+ }
+
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
&bo->base.base.handle.s32);
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
return image;
}
+static GLboolean
+intel_validate_usage(__DRIimage *image, unsigned int use)
+{
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (image->region->width != 64 || image->region->height != 64)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
static struct __DRIimageExtensionRec intelImageExtension = {
- { __DRI_IMAGE, __DRI_IMAGE_VERSION },
+ { __DRI_IMAGE, 2 },
intel_create_image_from_name,
intel_create_image_from_renderbuffer,
intel_destroy_image,
intel_create_image,
intel_query_image,
- intel_dup_image
+ intel_dup_image,
+ intel_validate_usage
};
static const __DRIextension *intelScreenExtensions[] = {
}
static struct __DRIimageExtensionRec radeonImageExtension = {
- { __DRI_IMAGE, __DRI_IMAGE_VERSION },
+ { __DRI_IMAGE, 1 },
radeon_create_image_from_name,
radeon_create_image_from_renderbuffer,
radeon_destroy_image,