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