1 #ifndef EGLIMAGE_INCLUDED
2 #define EGLIMAGE_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
10 * "Base" class for device driver images.
14 /* An image is a display resource */
15 _EGLResource Resource
;
22 _eglInitImage(_EGLDriver
*drv
, _EGLImage
*img
, const EGLint
*attrib_list
);
26 _eglCreateImageKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
,
27 EGLenum target
, EGLClientBuffer buffer
, const EGLint
*attr_list
);
31 _eglDestroyImageKHR(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLImage
*image
);
35 * Link an image to a display and return the handle of the link.
36 * The handle can be passed to client directly.
38 static INLINE EGLImageKHR
39 _eglLinkImage(_EGLImage
*img
, _EGLDisplay
*dpy
)
41 _eglLinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
, dpy
);
42 return (EGLImageKHR
) img
;
47 * Unlink a linked image from its display.
48 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
51 _eglUnlinkImage(_EGLImage
*img
)
53 _eglUnlinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
58 * Lookup a handle to find the linked image.
59 * Return NULL if the handle has no corresponding linked image.
61 static INLINE _EGLImage
*
62 _eglLookupImage(EGLImageKHR image
, _EGLDisplay
*dpy
)
64 _EGLImage
*img
= (_EGLImage
*) image
;
65 if (!dpy
|| !_eglCheckResource((void *) img
, _EGL_RESOURCE_IMAGE
, dpy
))
72 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
74 static INLINE EGLImageKHR
75 _eglGetImageHandle(_EGLImage
*img
)
77 _EGLResource
*res
= (_EGLResource
*) img
;
78 return (res
&& _eglIsResourceLinked(res
)) ?
79 (EGLImageKHR
) img
: EGL_NO_IMAGE_KHR
;
84 * Return true if the image is linked to a display.
86 static INLINE EGLBoolean
87 _eglIsImageLinked(_EGLImage
*img
)
89 _EGLResource
*res
= (_EGLResource
*) img
;
90 return (res
&& _eglIsResourceLinked(res
));
94 #endif /* EGLIMAGE_INCLUDED */