egl: Move fallback routines to eglfallbacks.c.
[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 /* EGL_MESA_drm_image */
19 EGLint Width;
20 EGLint Height;
21 EGLint DRMBufferFormatMESA;
22 EGLint DRMBufferUseMESA;
23 EGLint DRMBufferStrideMESA;
24 };
25
26 /**
27 * "Base" class for device driver images.
28 */
29 struct _egl_image
30 {
31 /* An image is a display resource */
32 _EGLResource Resource;
33 };
34
35
36 PUBLIC EGLint
37 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
38 const EGLint *attrib_list);
39
40
41 PUBLIC EGLBoolean
42 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy);
43
44
45 /**
46 * Link an image to a display and return the handle of the link.
47 * The handle can be passed to client directly.
48 */
49 static INLINE EGLImageKHR
50 _eglLinkImage(_EGLImage *img, _EGLDisplay *dpy)
51 {
52 _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy);
53 return (EGLImageKHR) img;
54 }
55
56
57 /**
58 * Unlink a linked image from its display.
59 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
60 */
61 static INLINE void
62 _eglUnlinkImage(_EGLImage *img)
63 {
64 _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
65 }
66
67
68 /**
69 * Lookup a handle to find the linked image.
70 * Return NULL if the handle has no corresponding linked image.
71 */
72 static INLINE _EGLImage *
73 _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
74 {
75 _EGLImage *img = (_EGLImage *) image;
76 if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
77 img = NULL;
78 return img;
79 }
80
81
82 /**
83 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
84 */
85 static INLINE EGLImageKHR
86 _eglGetImageHandle(_EGLImage *img)
87 {
88 _EGLResource *res = (_EGLResource *) img;
89 return (res && _eglIsResourceLinked(res)) ?
90 (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
91 }
92
93
94 /**
95 * Return true if the image is linked to a display.
96 */
97 static INLINE EGLBoolean
98 _eglIsImageLinked(_EGLImage *img)
99 {
100 _EGLResource *res = (_EGLResource *) img;
101 return (res && _eglIsResourceLinked(res));
102 }
103
104
105 #endif /* EGLIMAGE_INCLUDED */