egl: Move attributes in _EGLImage to _EGLImageAttribs.
[mesa.git] / src / egl / main / eglimage.h
1 #ifndef EGLIMAGE_INCLUDED
2 #define EGLIMAGE_INCLUDED
3
4
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
7
8
9 struct _egl_image_attribs
10 {
11 /* EGL_KHR_image_base */
12 EGLBoolean ImagePreserved;
13
14 /* EGL_KHR_gl_image */
15 EGLint GLTextureLevel;
16 EGLint GLTextureZOffset;
17 };
18
19 /**
20 * "Base" class for device driver images.
21 */
22 struct _egl_image
23 {
24 /* An image is a display resource */
25 _EGLResource Resource;
26 };
27
28
29 PUBLIC EGLint
30 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
31 const EGLint *attrib_list);
32
33
34 PUBLIC EGLBoolean
35 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy);
36
37
38 extern _EGLImage *
39 _eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
40 EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
41
42
43 extern EGLBoolean
44 _eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
45
46
47 /**
48 * Link an image to a display and return the handle of the link.
49 * The handle can be passed to client directly.
50 */
51 static INLINE EGLImageKHR
52 _eglLinkImage(_EGLImage *img, _EGLDisplay *dpy)
53 {
54 _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy);
55 return (EGLImageKHR) img;
56 }
57
58
59 /**
60 * Unlink a linked image from its display.
61 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
62 */
63 static INLINE void
64 _eglUnlinkImage(_EGLImage *img)
65 {
66 _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
67 }
68
69
70 /**
71 * Lookup a handle to find the linked image.
72 * Return NULL if the handle has no corresponding linked image.
73 */
74 static INLINE _EGLImage *
75 _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
76 {
77 _EGLImage *img = (_EGLImage *) image;
78 if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
79 img = NULL;
80 return img;
81 }
82
83
84 /**
85 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
86 */
87 static INLINE EGLImageKHR
88 _eglGetImageHandle(_EGLImage *img)
89 {
90 _EGLResource *res = (_EGLResource *) img;
91 return (res && _eglIsResourceLinked(res)) ?
92 (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
93 }
94
95
96 /**
97 * Return true if the image is linked to a display.
98 */
99 static INLINE EGLBoolean
100 _eglIsImageLinked(_EGLImage *img)
101 {
102 _EGLResource *res = (_EGLResource *) img;
103 return (res && _eglIsResourceLinked(res));
104 }
105
106
107 #endif /* EGLIMAGE_INCLUDED */