* with new lookup functions.
*/
#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
-#define __DRI_IMAGE_LOOKUP_VERSION 1
+#define __DRI_IMAGE_LOOKUP_VERSION 2
typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
struct __DRIimageLookupExtensionRec {
__DRIextension base;
+ /**
+ * Lookup EGLImage without validated. Equivalent to call
+ * validateEGLImage() then lookupEGLImageValidated().
+ *
+ * \since 1
+ */
__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
void *loaderPrivate);
+
+ /**
+ * Check if EGLImage is associated with the EGL display before lookup with
+ * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated
+ * out from lookupEGLImage() to avoid deadlock.
+ *
+ * \since 2
+ */
+ GLboolean (*validateEGLImage)(void *image, void *loaderPrivate);
+
+ /**
+ * Lookup EGLImage after validateEGLImage(). No lock in this function.
+ *
+ * \since 2
+ */
+ __DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate);
};
/**
return (config_count != 0);
}
-__DRIimage *
-dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
+GLboolean
+dri2_validate_egl_image(void *image, void *data)
{
_EGLDisplay *disp = data;
- struct dri2_egl_image *dri2_img;
_EGLImage *img;
- (void) screen;
-
mtx_lock(&disp->Mutex);
img = _eglLookupImage(image, disp);
mtx_unlock(&disp->Mutex);
if (img == NULL) {
- _eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image");
- return NULL;
+ _eglError(EGL_BAD_PARAMETER, "dri2_validate_egl_image");
+ return false;
}
+ return true;
+}
+
+__DRIimage *
+dri2_lookup_egl_image_validated(void *image, void *data)
+{
+ struct dri2_egl_image *dri2_img;
+
+ (void)data;
+
dri2_img = dri2_egl_image(image);
return dri2_img->dri_image;
}
+__DRIimage *
+dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
+{
+ (void) screen;
+
+ if (!dri2_validate_egl_image(image, data))
+ return NULL;
+
+ return dri2_lookup_egl_image_validated(image, data);
+}
+
const __DRIimageLookupExtension image_lookup_extension = {
- .base = { __DRI_IMAGE_LOOKUP, 1 },
+ .base = { __DRI_IMAGE_LOOKUP, 2 },
- .lookupEGLImage = dri2_lookup_egl_image
+ .lookupEGLImage = dri2_lookup_egl_image,
+ .validateEGLImage = dri2_validate_egl_image,
+ .lookupEGLImageValidated = dri2_lookup_egl_image_validated,
};
struct dri2_extension_match {
__DRIdrawable *
dri2_surface_get_dri_drawable(_EGLSurface *surf);
+GLboolean
+dri2_validate_egl_image(void *image, void *data);
+
+__DRIimage *
+dri2_lookup_egl_image_validated(void *image, void *data);
+
__DRIimage *
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);