egl: Make lookup functions static inline.
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4 #ifdef _EGL_PLATFORM_X
5 #include <X11/Xlib.h>
6 #endif
7
8 #include "egltypedefs.h"
9 #include "egldefines.h"
10 #include "eglcontext.h"
11 #include "eglsurface.h"
12
13
14 /**
15 * Optional EGL extensions info.
16 */
17 struct _egl_extensions
18 {
19 EGLBoolean MESA_screen_surface;
20 EGLBoolean MESA_copy_context;
21
22 char String[_EGL_MAX_EXTENSIONS_LEN];
23 };
24
25
26 struct _egl_display
27 {
28 /* used to link displays */
29 _EGLDisplay *Next;
30
31 EGLNativeDisplayType NativeDisplay;
32
33 const char *DriverName;
34 _EGLDriver *Driver;
35 void *DriverData; /* private to driver */
36
37 int APImajor, APIminor; /**< as returned by eglInitialize() */
38 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
39
40 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
41 EGLint ClientAPIsMask;
42 char ClientAPIs[1000]; /**< updated by eglQueryString */
43
44 _EGLExtensions Extensions;
45
46 int LargestPbuffer;
47
48 EGLint NumScreens;
49 _EGLScreen **Screens; /* array [NumScreens] */
50
51 EGLint NumConfigs;
52 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
53
54 /* lists of linked contexts and surface */
55 _EGLContext *ContextList;
56 _EGLSurface *SurfaceList;
57
58 #ifdef _EGL_PLATFORM_X
59 Display *Xdpy;
60 #endif
61 };
62
63
64 extern void
65 _eglFiniDisplay(void);
66
67
68 extern _EGLDisplay *
69 _eglNewDisplay(NativeDisplayType displayName);
70
71
72 extern EGLDisplay
73 _eglLinkDisplay(_EGLDisplay *dpy);
74
75
76 extern void
77 _eglUnlinkDisplay(_EGLDisplay *dpy);
78
79
80 extern _EGLDisplay *
81 _eglFindDisplay(NativeDisplayType nativeDisplay);
82
83
84 extern void
85 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
86
87
88 extern void
89 _eglCleanupDisplay(_EGLDisplay *disp);
90
91
92 extern EGLContext
93 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
94
95
96 extern void
97 _eglUnlinkContext(_EGLContext *ctx);
98
99
100 extern EGLSurface
101 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
102
103
104 extern void
105 _eglUnlinkSurface(_EGLSurface *surf);
106
107
108 /**
109 * Lookup a handle to find the linked display.
110 * Return NULL if the handle has no corresponding linked display.
111 */
112 static INLINE _EGLDisplay *
113 _eglLookupDisplay(EGLDisplay display)
114 {
115 _EGLDisplay *dpy = (_EGLDisplay *) display;
116 return dpy;
117 }
118
119
120 /**
121 * Return the handle of a linked display, or EGL_NO_DISPLAY.
122 */
123 static INLINE EGLDisplay
124 _eglGetDisplayHandle(_EGLDisplay *dpy)
125 {
126 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
127 }
128
129
130 /**
131 * Return true if the display is linked.
132 */
133 static INLINE EGLBoolean
134 _eglIsDisplayLinked(_EGLDisplay *dpy)
135 {
136 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
137 }
138
139
140 /**
141 * Lookup a handle to find the linked context.
142 * Return NULL if the handle has no corresponding linked context.
143 */
144 static INLINE _EGLContext *
145 _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
146 {
147 _EGLContext *ctx = (_EGLContext *) context;
148 return (ctx && ctx->Display) ? ctx : NULL;
149 }
150
151
152 /**
153 * Return the handle of a linked context, or EGL_NO_CONTEXT.
154 */
155 static INLINE EGLContext
156 _eglGetContextHandle(_EGLContext *ctx)
157 {
158 return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT);
159 }
160
161
162 /**
163 * Return true if the context is linked to a display.
164 */
165 static INLINE EGLBoolean
166 _eglIsContextLinked(_EGLContext *ctx)
167 {
168 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
169 }
170
171
172 /**
173 * Lookup a handle to find the linked surface.
174 * Return NULL if the handle has no corresponding linked surface.
175 */
176 static INLINE _EGLSurface *
177 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
178 {
179 _EGLSurface *surf = (_EGLSurface *) surface;
180 return (surf && surf->Display) ? surf : NULL;
181 }
182
183
184 /**
185 * Return the handle of a linked surface, or EGL_NO_SURFACE.
186 */
187 static INLINE EGLSurface
188 _eglGetSurfaceHandle(_EGLSurface *surf)
189 {
190 return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
191 }
192
193
194 /**
195 * Return true if the surface is linked to a display.
196 */
197 static INLINE EGLBoolean
198 _eglIsSurfaceLinked(_EGLSurface *surf)
199 {
200 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
201 }
202
203
204 /**
205 * Cast an unsigned int to a pointer.
206 */
207 static INLINE void *
208 _eglUIntToPointer(unsigned int v)
209 {
210 return (void *) ((uintptr_t) v);
211 }
212
213
214 /**
215 * Cast a pointer to an unsigned int. The pointer must be one that is
216 * returned by _eglUIntToPointer.
217 */
218 static INLINE unsigned int
219 _eglPointerToUInt(const void *p)
220 {
221 return (unsigned int) ((uintptr_t) p);
222 }
223
224
225 #endif /* EGLDISPLAY_INCLUDED */