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 * Increment reference count for the image.
48 static INLINE _EGLImage
*
49 _eglGetImage(_EGLImage
*img
)
52 _eglGetResource(&img
->Resource
);
58 * Decrement reference count for the image.
60 static INLINE EGLBoolean
61 _eglPutImage(_EGLImage
*img
)
63 return (img
) ? _eglPutResource(&img
->Resource
) : EGL_FALSE
;
68 * Link an image to its display and return the handle of the link.
69 * The handle can be passed to client directly.
71 static INLINE EGLImageKHR
72 _eglLinkImage(_EGLImage
*img
)
74 _eglLinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
75 return (EGLImageKHR
) img
;
80 * Unlink a linked image from its display.
81 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
84 _eglUnlinkImage(_EGLImage
*img
)
86 _eglUnlinkResource(&img
->Resource
, _EGL_RESOURCE_IMAGE
);
91 * Lookup a handle to find the linked image.
92 * Return NULL if the handle has no corresponding linked image.
94 static INLINE _EGLImage
*
95 _eglLookupImage(EGLImageKHR image
, _EGLDisplay
*dpy
)
97 _EGLImage
*img
= (_EGLImage
*) image
;
98 if (!dpy
|| !_eglCheckResource((void *) img
, _EGL_RESOURCE_IMAGE
, dpy
))
105 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
107 static INLINE EGLImageKHR
108 _eglGetImageHandle(_EGLImage
*img
)
110 _EGLResource
*res
= (_EGLResource
*) img
;
111 return (res
&& _eglIsResourceLinked(res
)) ?
112 (EGLImageKHR
) img
: EGL_NO_IMAGE_KHR
;
116 #endif /* EGLIMAGE_INCLUDED */