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] */
48 _EGLConfig
**Configs
; /* array [NumConfigs] of ptr to _EGLConfig */
50 /* lists of linked contexts and surface */
51 _EGLContext
*ContextList
;
52 _EGLSurface
*SurfaceList
;
57 _eglFiniDisplay(void);
61 _eglSplitDisplayString(const char *dpyString
, const char **args
);
65 _eglNewDisplay(NativeDisplayType displayName
);
69 _eglLinkDisplay(_EGLDisplay
*dpy
);
73 _eglUnlinkDisplay(_EGLDisplay
*dpy
);
77 _eglFindDisplay(NativeDisplayType nativeDisplay
);
81 _eglReleaseDisplayResources(_EGLDriver
*drv
, _EGLDisplay
*dpy
);
85 _eglCleanupDisplay(_EGLDisplay
*disp
);
89 _eglLinkContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
);
93 _eglUnlinkContext(_EGLContext
*ctx
);
97 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
);
101 _eglUnlinkSurface(_EGLSurface
*surf
);
104 #ifndef _EGL_SKIP_HANDLE_CHECK
108 _eglCheckDisplayHandle(EGLDisplay dpy
);
112 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
);
116 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
);
119 #else /* !_EGL_SKIP_HANDLE_CHECK */
121 /* Only do a quick check. This is NOT standard compliant. */
123 static INLINE EGLBoolean
124 _eglCheckDisplayHandle(EGLDisplay dpy
)
126 return ((_EGLDisplay
*) dpy
!= NULL
);
130 static INLINE EGLBoolean
131 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
)
133 _EGLContext
*c
= (_EGLContext
*) ctx
;
134 return (dpy
&& c
&& c
->Display
== dpy
);
138 static INLINE EGLBoolean
139 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
)
141 _EGLSurface
*s
= (_EGLSurface
*) surf
;
142 return (dpy
&& s
&& s
->Display
== dpy
);
146 #endif /* _EGL_SKIP_HANDLE_CHECK */
150 * Lookup a handle to find the linked display.
151 * Return NULL if the handle has no corresponding linked display.
153 static INLINE _EGLDisplay
*
154 _eglLookupDisplay(EGLDisplay display
)
156 _EGLDisplay
*dpy
= (_EGLDisplay
*) display
;
157 if (!_eglCheckDisplayHandle(display
))
164 * Return the handle of a linked display, or EGL_NO_DISPLAY.
166 static INLINE EGLDisplay
167 _eglGetDisplayHandle(_EGLDisplay
*dpy
)
169 return (EGLDisplay
) ((dpy
) ? dpy
: EGL_NO_DISPLAY
);
174 * Return true if the display is linked.
176 static INLINE EGLBoolean
177 _eglIsDisplayLinked(_EGLDisplay
*dpy
)
179 return (EGLBoolean
) (_eglGetDisplayHandle(dpy
) != EGL_NO_DISPLAY
);
184 * Lookup a handle to find the linked context.
185 * Return NULL if the handle has no corresponding linked context.
187 static INLINE _EGLContext
*
188 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
190 _EGLContext
*ctx
= (_EGLContext
*) context
;
191 if (!_eglCheckContextHandle(context
, dpy
))
198 * Return the handle of a linked context, or EGL_NO_CONTEXT.
200 static INLINE EGLContext
201 _eglGetContextHandle(_EGLContext
*ctx
)
203 return (EGLContext
) ((ctx
&& ctx
->Display
) ? ctx
: EGL_NO_CONTEXT
);
208 * Return true if the context is linked to a display.
210 static INLINE EGLBoolean
211 _eglIsContextLinked(_EGLContext
*ctx
)
213 return (EGLBoolean
) (_eglGetContextHandle(ctx
) != EGL_NO_CONTEXT
);
218 * Lookup a handle to find the linked surface.
219 * Return NULL if the handle has no corresponding linked surface.
221 static INLINE _EGLSurface
*
222 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
224 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
225 if (!_eglCheckSurfaceHandle(surf
, dpy
))
232 * Return the handle of a linked surface, or EGL_NO_SURFACE.
234 static INLINE EGLSurface
235 _eglGetSurfaceHandle(_EGLSurface
*surf
)
237 return (EGLSurface
) ((surf
&& surf
->Display
) ? surf
: EGL_NO_SURFACE
);
242 * Return true if the surface is linked to a display.
244 static INLINE EGLBoolean
245 _eglIsSurfaceLinked(_EGLSurface
*surf
)
247 return (EGLBoolean
) (_eglGetSurfaceHandle(surf
) != EGL_NO_SURFACE
);
252 * Cast an unsigned int to a pointer.
255 _eglUIntToPointer(unsigned int v
)
257 return (void *) ((uintptr_t) v
);
262 * Cast a pointer to an unsigned int. The pointer must be one that is
263 * returned by _eglUIntToPointer.
265 static INLINE
unsigned int
266 _eglPointerToUInt(const void *p
)
268 return (unsigned int) ((uintptr_t) p
);
272 #endif /* EGLDISPLAY_INCLUDED */