1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
8 #include "egltypedefs.h"
9 #include "egldefines.h"
10 #include "eglcontext.h"
11 #include "eglsurface.h"
15 * Optional EGL extensions info.
17 struct _egl_extensions
19 EGLBoolean MESA_screen_surface
;
20 EGLBoolean MESA_copy_context
;
22 char String
[_EGL_MAX_EXTENSIONS_LEN
];
28 /* used to link displays */
31 EGLNativeDisplayType NativeDisplay
;
33 const char *DriverName
;
35 void *DriverData
; /* private to driver */
37 int APImajor
, APIminor
; /**< as returned by eglInitialize() */
38 char Version
[1000]; /**< initialized from APImajor/minor, DriverName */
40 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
41 EGLint ClientAPIsMask
;
42 char ClientAPIs
[1000]; /**< updated by eglQueryString */
44 _EGLExtensions Extensions
;
49 _EGLScreen
**Screens
; /* array [NumScreens] */
52 _EGLConfig
**Configs
; /* array [NumConfigs] of ptr to _EGLConfig */
54 /* lists of linked contexts and surface */
55 _EGLContext
*ContextList
;
56 _EGLSurface
*SurfaceList
;
58 #ifdef _EGL_PLATFORM_X
65 _eglFiniDisplay(void);
69 _eglSplitDisplayString(const char *dpyString
, const char **args
);
73 _eglNewDisplay(NativeDisplayType displayName
);
77 _eglLinkDisplay(_EGLDisplay
*dpy
);
81 _eglUnlinkDisplay(_EGLDisplay
*dpy
);
85 _eglFindDisplay(NativeDisplayType nativeDisplay
);
89 _eglReleaseDisplayResources(_EGLDriver
*drv
, _EGLDisplay
*dpy
);
93 _eglCleanupDisplay(_EGLDisplay
*disp
);
97 _eglLinkContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
);
101 _eglUnlinkContext(_EGLContext
*ctx
);
105 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
);
109 _eglUnlinkSurface(_EGLSurface
*surf
);
112 #ifndef _EGL_SKIP_HANDLE_CHECK
116 _eglCheckDisplayHandle(EGLDisplay dpy
);
120 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
);
124 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
);
127 #else /* !_EGL_SKIP_HANDLE_CHECK */
129 /* Only do a quick check. This is NOT standard compliant. */
131 static INLINE EGLBoolean
132 _eglCheckDisplayHandle(EGLDisplay dpy
)
134 return ((_EGLDisplay
*) dpy
!= NULL
);
138 static INLINE EGLBoolean
139 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
)
141 _EGLContext
*c
= (_EGLContext
*) ctx
;
142 return (dpy
&& c
&& c
->Display
== dpy
);
146 static INLINE EGLBoolean
147 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
)
149 _EGLSurface
*s
= (_EGLSurface
*) surf
;
150 return (dpy
&& s
&& s
->Display
== dpy
);
154 #endif /* _EGL_SKIP_HANDLE_CHECK */
158 * Lookup a handle to find the linked display.
159 * Return NULL if the handle has no corresponding linked display.
161 static INLINE _EGLDisplay
*
162 _eglLookupDisplay(EGLDisplay display
)
164 _EGLDisplay
*dpy
= (_EGLDisplay
*) display
;
165 if (!_eglCheckDisplayHandle(display
))
172 * Return the handle of a linked display, or EGL_NO_DISPLAY.
174 static INLINE EGLDisplay
175 _eglGetDisplayHandle(_EGLDisplay
*dpy
)
177 return (EGLDisplay
) ((dpy
) ? dpy
: EGL_NO_DISPLAY
);
182 * Return true if the display is linked.
184 static INLINE EGLBoolean
185 _eglIsDisplayLinked(_EGLDisplay
*dpy
)
187 return (EGLBoolean
) (_eglGetDisplayHandle(dpy
) != EGL_NO_DISPLAY
);
192 * Lookup a handle to find the linked context.
193 * Return NULL if the handle has no corresponding linked context.
195 static INLINE _EGLContext
*
196 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
198 _EGLContext
*ctx
= (_EGLContext
*) context
;
199 if (!_eglCheckContextHandle(context
, dpy
))
206 * Return the handle of a linked context, or EGL_NO_CONTEXT.
208 static INLINE EGLContext
209 _eglGetContextHandle(_EGLContext
*ctx
)
211 return (EGLContext
) ((ctx
&& ctx
->Display
) ? ctx
: EGL_NO_CONTEXT
);
216 * Return true if the context is linked to a display.
218 static INLINE EGLBoolean
219 _eglIsContextLinked(_EGLContext
*ctx
)
221 return (EGLBoolean
) (_eglGetContextHandle(ctx
) != EGL_NO_CONTEXT
);
226 * Lookup a handle to find the linked surface.
227 * Return NULL if the handle has no corresponding linked surface.
229 static INLINE _EGLSurface
*
230 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
232 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
233 if (!_eglCheckSurfaceHandle(surf
, dpy
))
240 * Return the handle of a linked surface, or EGL_NO_SURFACE.
242 static INLINE EGLSurface
243 _eglGetSurfaceHandle(_EGLSurface
*surf
)
245 return (EGLSurface
) ((surf
&& surf
->Display
) ? surf
: EGL_NO_SURFACE
);
250 * Return true if the surface is linked to a display.
252 static INLINE EGLBoolean
253 _eglIsSurfaceLinked(_EGLSurface
*surf
)
255 return (EGLBoolean
) (_eglGetSurfaceHandle(surf
) != EGL_NO_SURFACE
);
260 * Cast an unsigned int to a pointer.
263 _eglUIntToPointer(unsigned int v
)
265 return (void *) ((uintptr_t) v
);
270 * Cast a pointer to an unsigned int. The pointer must be one that is
271 * returned by _eglUIntToPointer.
273 static INLINE
unsigned int
274 _eglPointerToUInt(const void *p
)
276 return (unsigned int) ((uintptr_t) p
);
280 #endif /* EGLDISPLAY_INCLUDED */