st/xa: Fix crosscompile builds with nonstandard ld locations
[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 * Increment reference count for the image.
47 */
48 static INLINE _EGLImage *
49 _eglGetImage(_EGLImage *img)
50 {
51 if (img)
52 _eglGetResource(&img->Resource);
53 return img;
54 }
55
56
57 /**
58 * Decrement reference count for the image.
59 */
60 static INLINE EGLBoolean
61 _eglPutImage(_EGLImage *img)
62 {
63 return (img) ? _eglPutResource(&img->Resource) : EGL_FALSE;
64 }
65
66
67 /**
68 * Link an image to its display and return the handle of the link.
69 * The handle can be passed to client directly.
70 */
71 static INLINE EGLImageKHR
72 _eglLinkImage(_EGLImage *img)
73 {
74 _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
75 return (EGLImageKHR) img;
76 }
77
78
79 /**
80 * Unlink a linked image from its display.
81 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
82 */
83 static INLINE void
84 _eglUnlinkImage(_EGLImage *img)
85 {
86 _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
87 }
88
89
90 /**
91 * Lookup a handle to find the linked image.
92 * Return NULL if the handle has no corresponding linked image.
93 */
94 static INLINE _EGLImage *
95 _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
96 {
97 _EGLImage *img = (_EGLImage *) image;
98 if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
99 img = NULL;
100 return img;
101 }
102
103
104 /**
105 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
106 */
107 static INLINE EGLImageKHR
108 _eglGetImageHandle(_EGLImage *img)
109 {
110 _EGLResource *res = (_EGLResource *) img;
111 return (res && _eglIsResourceLinked(res)) ?
112 (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
113 }
114
115
116 #endif /* EGLIMAGE_INCLUDED */