1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
4 #include "egltypedefs.h"
5 #include "egldefines.h"
6 #include "eglcontext.h"
7 #include "eglsurface.h"
11 * Optional EGL extensions info.
13 struct _egl_extensions
15 EGLBoolean MESA_screen_surface;
16 EGLBoolean MESA_copy_context;
18 EGLBoolean KHR_image_base;
19 EGLBoolean KHR_image_pixmap;
21 char String[_EGL_MAX_EXTENSIONS_LEN];
27 /* used to link displays */
30 EGLNativeDisplayType NativeDisplay;
32 const char *DriverName;
34 void *DriverData; /* private to driver */
36 int APImajor, APIminor; /**< as returned by eglInitialize() */
37 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
39 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
40 EGLint ClientAPIsMask;
41 char ClientAPIs[1000]; /**< updated by eglQueryString */
43 _EGLExtensions Extensions;
48 _EGLScreen **Screens; /* array [NumScreens] */
51 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
53 /* lists of linked contexts and surface */
54 _EGLContext *ContextList;
55 _EGLSurface *SurfaceList;
62 _eglFiniDisplay(void);
66 _eglSplitDisplayString(const char *dpyString, const char **args);
70 _eglNewDisplay(NativeDisplayType displayName);
74 _eglLinkDisplay(_EGLDisplay *dpy);
78 _eglUnlinkDisplay(_EGLDisplay *dpy);
82 _eglFindDisplay(NativeDisplayType nativeDisplay);
86 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
90 _eglCleanupDisplay(_EGLDisplay *disp);
94 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
98 _eglUnlinkContext(_EGLContext *ctx);
102 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
106 _eglUnlinkSurface(_EGLSurface *surf);
109 #ifndef _EGL_SKIP_HANDLE_CHECK
113 _eglCheckDisplayHandle(EGLDisplay dpy);
117 _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy);
121 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy);
124 #else /* !_EGL_SKIP_HANDLE_CHECK */
126 /* Only do a quick check. This is NOT standard compliant. */
128 static INLINE EGLBoolean
129 _eglCheckDisplayHandle(EGLDisplay dpy)
131 return ((_EGLDisplay *) dpy != NULL);
135 static INLINE EGLBoolean
136 _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
138 _EGLContext *c = (_EGLContext *) ctx;
139 return (dpy && c && c->Display == dpy);
143 static INLINE EGLBoolean
144 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
146 _EGLSurface *s = (_EGLSurface *) surf;
147 return (dpy && s && s->Display == dpy);
151 #endif /* _EGL_SKIP_HANDLE_CHECK */
155 * Lookup a handle to find the linked display.
156 * Return NULL if the handle has no corresponding linked display.
158 static INLINE _EGLDisplay *
159 _eglLookupDisplay(EGLDisplay display)
161 _EGLDisplay *dpy = (_EGLDisplay *) display;
162 if (!_eglCheckDisplayHandle(display))
169 * Return the handle of a linked display, or EGL_NO_DISPLAY.
171 static INLINE EGLDisplay
172 _eglGetDisplayHandle(_EGLDisplay *dpy)
174 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
179 * Return true if the display is linked.
181 static INLINE EGLBoolean
182 _eglIsDisplayLinked(_EGLDisplay *dpy)
184 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
189 * Lookup a handle to find the linked context.
190 * Return NULL if the handle has no corresponding linked context.
192 static INLINE _EGLContext *
193 _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
195 _EGLContext *ctx = (_EGLContext *) context;
196 if (!_eglCheckContextHandle(context, dpy))
203 * Return the handle of a linked context, or EGL_NO_CONTEXT.
205 static INLINE EGLContext
206 _eglGetContextHandle(_EGLContext *ctx)
208 return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT);
213 * Return true if the context is linked to a display.
215 static INLINE EGLBoolean
216 _eglIsContextLinked(_EGLContext *ctx)
218 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
223 * Lookup a handle to find the linked surface.
224 * Return NULL if the handle has no corresponding linked surface.
226 static INLINE _EGLSurface *
227 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
229 _EGLSurface *surf = (_EGLSurface *) surface;
230 if (!_eglCheckSurfaceHandle(surf, dpy))
237 * Return the handle of a linked surface, or EGL_NO_SURFACE.
239 static INLINE EGLSurface
240 _eglGetSurfaceHandle(_EGLSurface *surf)
242 return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
247 * Return true if the surface is linked to a display.
249 static INLINE EGLBoolean
250 _eglIsSurfaceLinked(_EGLSurface *surf)
252 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
257 * Cast an unsigned int to a pointer.
260 _eglUIntToPointer(unsigned int v)
262 return (void *) ((uintptr_t) v);
267 * Cast a pointer to an unsigned int. The pointer must be one that is
268 * returned by _eglUIntToPointer.
270 static INLINE unsigned int
271 _eglPointerToUInt(const void *p)
273 return (unsigned int) ((uintptr_t) p);
277 #endif /* EGLDISPLAY_INCLUDED */