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
;
20 * "Base" class for device driver images.
24 /* An image is a display resource */
25 _EGLResource Resource
;
30 _eglParseImageAttribList(_EGLImageAttribs
*attrs
, _EGLDisplay
*dpy
,
31 const EGLint
*attrib_list
);
35 _eglInitImage(_EGLImage
*img
, _EGLDisplay
*dpy
);
39 _eglCreateImageKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
,
40 EGLenum target
, EGLClientBuffer buffer
, const EGLint
*attr_list
);
44 _eglDestroyImageKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLImage
*image
);
48 * Link an image to a display and return the handle of the link.
49 * The handle can be passed to client directly.
51 static INLINE EGLImageKHR
52 _eglLinkImage(_EGLImage
*img
, _EGLDisplay
*dpy
)
54 _eglLinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
, dpy
);
55 return (EGLImageKHR
) img
;
60 * Unlink a linked image from its display.
61 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
64 _eglUnlinkImage(_EGLImage
*img
)
66 _eglUnlinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
71 * Lookup a handle to find the linked image.
72 * Return NULL if the handle has no corresponding linked image.
74 static INLINE _EGLImage
*
75 _eglLookupImage(EGLImageKHR image
, _EGLDisplay
*dpy
)
77 _EGLImage
*img
= (_EGLImage
*) image
;
78 if (!dpy
|| !_eglCheckResource((void *) img
, _EGL_RESOURCE_IMAGE
, dpy
))
85 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
87 static INLINE EGLImageKHR
88 _eglGetImageHandle(_EGLImage
*img
)
90 _EGLResource
*res
= (_EGLResource
*) img
;
91 return (res
&& _eglIsResourceLinked(res
)) ?
92 (EGLImageKHR
) img
: EGL_NO_IMAGE_KHR
;
97 * Return true if the image is linked to a display.
99 static INLINE EGLBoolean
100 _eglIsImageLinked(_EGLImage
*img
)
102 _EGLResource
*res
= (_EGLResource
*) img
;
103 return (res
&& _eglIsResourceLinked(res
));
107 #endif /* EGLIMAGE_INCLUDED */