1 #ifndef EGLIMAGE_INCLUDED
2 #define EGLIMAGE_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
9 struct _egl_image_attribs
11 /* EGL_KHR_image_base */
12 EGLBoolean ImagePreserved
;
14 /* EGL_KHR_gl_image */
15 EGLint GLTextureLevel
;
16 EGLint GLTextureZOffset
;
18 /* EGL_MESA_drm_image */
21 EGLint DRMBufferFormatMESA
;
22 EGLint DRMBufferUseMESA
;
23 EGLint DRMBufferStrideMESA
;
27 * "Base" class for device driver images.
31 /* An image is a display resource */
32 _EGLResource Resource
;
37 _eglParseImageAttribList(_EGLImageAttribs
*attrs
, _EGLDisplay
*dpy
,
38 const EGLint
*attrib_list
);
42 _eglInitImage(_EGLImage
*img
, _EGLDisplay
*dpy
);
46 * Link an image to its display and return the handle of the link.
47 * The handle can be passed to client directly.
49 static INLINE EGLImageKHR
50 _eglLinkImage(_EGLImage
*img
)
52 _eglLinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
53 return (EGLImageKHR
) img
;
58 * Unlink a linked image from its display.
59 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
62 _eglUnlinkImage(_EGLImage
*img
)
64 _eglUnlinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
69 * Lookup a handle to find the linked image.
70 * Return NULL if the handle has no corresponding linked image.
72 static INLINE _EGLImage
*
73 _eglLookupImage(EGLImageKHR image
, _EGLDisplay
*dpy
)
75 _EGLImage
*img
= (_EGLImage
*) image
;
76 if (!dpy
|| !_eglCheckResource((void *) img
, _EGL_RESOURCE_IMAGE
, dpy
))
83 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
85 static INLINE EGLImageKHR
86 _eglGetImageHandle(_EGLImage
*img
)
88 _EGLResource
*res
= (_EGLResource
*) img
;
89 return (res
&& _eglIsResourceLinked(res
)) ?
90 (EGLImageKHR
) img
: EGL_NO_IMAGE_KHR
;
95 * Return true if the image is linked to a display.
97 static INLINE EGLBoolean
98 _eglIsImageLinked(_EGLImage
*img
)
100 _EGLResource
*res
= (_EGLResource
*) img
;
101 return (res
&& _eglIsResourceLinked(res
));
105 #endif /* EGLIMAGE_INCLUDED */