Merge branch 'gallium-nopointsizeminmax'
[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 /**
10 * "Base" class for device driver images.
11 */
12 struct _egl_image
13 {
14 /* An image is a display resource */
15 _EGLResource Resource;
16
17 EGLBoolean Preserved;
18 EGLint GLTextureLevel;
19 EGLint GLTextureZOffset;
20 };
21
22
23 PUBLIC EGLBoolean
24 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy, const EGLint *attrib_list);
25
26
27 extern _EGLImage *
28 _eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
29 EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
30
31
32 extern EGLBoolean
33 _eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
34
35
36 /**
37 * Link an image to a display and return the handle of the link.
38 * The handle can be passed to client directly.
39 */
40 static INLINE EGLImageKHR
41 _eglLinkImage(_EGLImage *img, _EGLDisplay *dpy)
42 {
43 _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy);
44 return (EGLImageKHR) img;
45 }
46
47
48 /**
49 * Unlink a linked image from its display.
50 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
51 */
52 static INLINE void
53 _eglUnlinkImage(_EGLImage *img)
54 {
55 _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
56 }
57
58
59 /**
60 * Lookup a handle to find the linked image.
61 * Return NULL if the handle has no corresponding linked image.
62 */
63 static INLINE _EGLImage *
64 _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
65 {
66 _EGLImage *img = (_EGLImage *) image;
67 if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
68 img = NULL;
69 return img;
70 }
71
72
73 /**
74 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
75 */
76 static INLINE EGLImageKHR
77 _eglGetImageHandle(_EGLImage *img)
78 {
79 _EGLResource *res = (_EGLResource *) img;
80 return (res && _eglIsResourceLinked(res)) ?
81 (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
82 }
83
84
85 /**
86 * Return true if the image is linked to a display.
87 */
88 static INLINE EGLBoolean
89 _eglIsImageLinked(_EGLImage *img)
90 {
91 _EGLResource *res = (_EGLResource *) img;
92 return (res && _eglIsResourceLinked(res));
93 }
94
95
96 #endif /* EGLIMAGE_INCLUDED */