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 char String
[_EGL_MAX_EXTENSIONS_LEN
];
24 /* used to link displays */
27 EGLNativeDisplayType NativeDisplay
;
29 const char *DriverName
;
31 void *DriverData
; /* private to driver */
33 int APImajor
, APIminor
; /**< as returned by eglInitialize() */
34 char Version
[1000]; /**< initialized from APImajor/minor, DriverName */
36 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
37 EGLint ClientAPIsMask
;
38 char ClientAPIs
[1000]; /**< updated by eglQueryString */
40 _EGLExtensions Extensions
;
45 _EGLScreen
**Screens
; /* array [NumScreens] */
49 _EGLConfig
**Configs
; /* array [NumConfigs] of ptr to _EGLConfig */
51 /* lists of linked contexts and surface */
52 _EGLContext
*ContextList
;
53 _EGLSurface
*SurfaceList
;
58 _eglFiniDisplay(void);
62 _eglSplitDisplayString(const char *dpyString
, const char **args
);
66 _eglNewDisplay(NativeDisplayType displayName
);
70 _eglLinkDisplay(_EGLDisplay
*dpy
);
74 _eglUnlinkDisplay(_EGLDisplay
*dpy
);
78 _eglFindDisplay(NativeDisplayType nativeDisplay
);
82 _eglReleaseDisplayResources(_EGLDriver
*drv
, _EGLDisplay
*dpy
);
86 _eglCleanupDisplay(_EGLDisplay
*disp
);
90 _eglLinkContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
);
94 _eglUnlinkContext(_EGLContext
*ctx
);
98 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
);
102 _eglUnlinkSurface(_EGLSurface
*surf
);
105 #ifndef _EGL_SKIP_HANDLE_CHECK
109 _eglCheckDisplayHandle(EGLDisplay dpy
);
113 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
);
117 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
);
120 #else /* !_EGL_SKIP_HANDLE_CHECK */
122 /* Only do a quick check. This is NOT standard compliant. */
124 static INLINE EGLBoolean
125 _eglCheckDisplayHandle(EGLDisplay dpy
)
127 return ((_EGLDisplay
*) dpy
!= NULL
);
131 static INLINE EGLBoolean
132 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
)
134 _EGLContext
*c
= (_EGLContext
*) ctx
;
135 return (dpy
&& c
&& c
->Display
== dpy
);
139 static INLINE EGLBoolean
140 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
)
142 _EGLSurface
*s
= (_EGLSurface
*) surf
;
143 return (dpy
&& s
&& s
->Display
== dpy
);
147 #endif /* _EGL_SKIP_HANDLE_CHECK */
151 * Lookup a handle to find the linked display.
152 * Return NULL if the handle has no corresponding linked display.
154 static INLINE _EGLDisplay
*
155 _eglLookupDisplay(EGLDisplay display
)
157 _EGLDisplay
*dpy
= (_EGLDisplay
*) display
;
158 if (!_eglCheckDisplayHandle(display
))
165 * Return the handle of a linked display, or EGL_NO_DISPLAY.
167 static INLINE EGLDisplay
168 _eglGetDisplayHandle(_EGLDisplay
*dpy
)
170 return (EGLDisplay
) ((dpy
) ? dpy
: EGL_NO_DISPLAY
);
175 * Return true if the display is linked.
177 static INLINE EGLBoolean
178 _eglIsDisplayLinked(_EGLDisplay
*dpy
)
180 return (EGLBoolean
) (_eglGetDisplayHandle(dpy
) != EGL_NO_DISPLAY
);
185 * Lookup a handle to find the linked context.
186 * Return NULL if the handle has no corresponding linked context.
188 static INLINE _EGLContext
*
189 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
191 _EGLContext
*ctx
= (_EGLContext
*) context
;
192 if (!_eglCheckContextHandle(context
, dpy
))
199 * Return the handle of a linked context, or EGL_NO_CONTEXT.
201 static INLINE EGLContext
202 _eglGetContextHandle(_EGLContext
*ctx
)
204 return (EGLContext
) ((ctx
&& ctx
->Display
) ? ctx
: EGL_NO_CONTEXT
);
209 * Return true if the context is linked to a display.
211 static INLINE EGLBoolean
212 _eglIsContextLinked(_EGLContext
*ctx
)
214 return (EGLBoolean
) (_eglGetContextHandle(ctx
) != EGL_NO_CONTEXT
);
219 * Lookup a handle to find the linked surface.
220 * Return NULL if the handle has no corresponding linked surface.
222 static INLINE _EGLSurface
*
223 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
225 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
226 if (!_eglCheckSurfaceHandle(surf
, dpy
))
233 * Return the handle of a linked surface, or EGL_NO_SURFACE.
235 static INLINE EGLSurface
236 _eglGetSurfaceHandle(_EGLSurface
*surf
)
238 return (EGLSurface
) ((surf
&& surf
->Display
) ? surf
: EGL_NO_SURFACE
);
243 * Return true if the surface is linked to a display.
245 static INLINE EGLBoolean
246 _eglIsSurfaceLinked(_EGLSurface
*surf
)
248 return (EGLBoolean
) (_eglGetSurfaceHandle(surf
) != EGL_NO_SURFACE
);
253 * Cast an unsigned int to a pointer.
256 _eglUIntToPointer(unsigned int v
)
258 return (void *) ((uintptr_t) v
);
263 * Cast a pointer to an unsigned int. The pointer must be one that is
264 * returned by _eglUIntToPointer.
266 static INLINE
unsigned int
267 _eglPointerToUInt(const void *p
)
269 return (unsigned int) ((uintptr_t) p
);
273 #endif /* EGLDISPLAY_INCLUDED */