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 _eglNewDisplay(NativeDisplayType displayName
);
66 _eglLinkDisplay(_EGLDisplay
*dpy
);
70 _eglUnlinkDisplay(_EGLDisplay
*dpy
);
74 _eglFindDisplay(NativeDisplayType nativeDisplay
);
78 _eglReleaseDisplayResources(_EGLDriver
*drv
, _EGLDisplay
*dpy
);
82 _eglCleanupDisplay(_EGLDisplay
*disp
);
86 _eglLinkContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
);
90 _eglUnlinkContext(_EGLContext
*ctx
);
94 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
);
98 _eglUnlinkSurface(_EGLSurface
*surf
);
101 #ifndef _EGL_SKIP_HANDLE_CHECK
105 _eglCheckDisplayHandle(EGLDisplay dpy
);
109 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
);
113 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
);
116 #else /* !_EGL_SKIP_HANDLE_CHECK */
118 /* Only do a quick check. This is NOT standard compliant. */
120 static INLINE EGLBoolean
121 _eglCheckDisplayHandle(EGLDisplay dpy
)
123 return ((_EGLDisplay
*) dpy
!= NULL
);
127 static INLINE EGLBoolean
128 _eglCheckContextHandle(EGLContext ctx
, _EGLDisplay
*dpy
)
130 _EGLContext
*c
= (_EGLContext
*) ctx
;
131 return (dpy
&& c
&& c
->Display
== dpy
);
135 static INLINE EGLBoolean
136 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
)
138 _EGLSurface
*s
= (_EGLSurface
*) surf
;
139 return (dpy
&& s
&& s
->Display
== dpy
);
143 #endif /* _EGL_SKIP_HANDLE_CHECK */
147 * Lookup a handle to find the linked display.
148 * Return NULL if the handle has no corresponding linked display.
150 static INLINE _EGLDisplay
*
151 _eglLookupDisplay(EGLDisplay display
)
153 _EGLDisplay
*dpy
= (_EGLDisplay
*) display
;
154 if (!_eglCheckDisplayHandle(display
))
161 * Return the handle of a linked display, or EGL_NO_DISPLAY.
163 static INLINE EGLDisplay
164 _eglGetDisplayHandle(_EGLDisplay
*dpy
)
166 return (EGLDisplay
) ((dpy
) ? dpy
: EGL_NO_DISPLAY
);
171 * Return true if the display is linked.
173 static INLINE EGLBoolean
174 _eglIsDisplayLinked(_EGLDisplay
*dpy
)
176 return (EGLBoolean
) (_eglGetDisplayHandle(dpy
) != EGL_NO_DISPLAY
);
181 * Lookup a handle to find the linked context.
182 * Return NULL if the handle has no corresponding linked context.
184 static INLINE _EGLContext
*
185 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
187 _EGLContext
*ctx
= (_EGLContext
*) context
;
188 if (!_eglCheckContextHandle(context
, dpy
))
195 * Return the handle of a linked context, or EGL_NO_CONTEXT.
197 static INLINE EGLContext
198 _eglGetContextHandle(_EGLContext
*ctx
)
200 return (EGLContext
) ((ctx
&& ctx
->Display
) ? ctx
: EGL_NO_CONTEXT
);
205 * Return true if the context is linked to a display.
207 static INLINE EGLBoolean
208 _eglIsContextLinked(_EGLContext
*ctx
)
210 return (EGLBoolean
) (_eglGetContextHandle(ctx
) != EGL_NO_CONTEXT
);
215 * Lookup a handle to find the linked surface.
216 * Return NULL if the handle has no corresponding linked surface.
218 static INLINE _EGLSurface
*
219 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
221 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
222 if (!_eglCheckSurfaceHandle(surf
, dpy
))
229 * Return the handle of a linked surface, or EGL_NO_SURFACE.
231 static INLINE EGLSurface
232 _eglGetSurfaceHandle(_EGLSurface
*surf
)
234 return (EGLSurface
) ((surf
&& surf
->Display
) ? surf
: EGL_NO_SURFACE
);
239 * Return true if the surface is linked to a display.
241 static INLINE EGLBoolean
242 _eglIsSurfaceLinked(_EGLSurface
*surf
)
244 return (EGLBoolean
) (_eglGetSurfaceHandle(surf
) != EGL_NO_SURFACE
);
249 * Cast an unsigned int to a pointer.
252 _eglUIntToPointer(unsigned int v
)
254 return (void *) ((uintptr_t) v
);
259 * Cast a pointer to an unsigned int. The pointer must be one that is
260 * returned by _eglUIntToPointer.
262 static INLINE
unsigned int
263 _eglPointerToUInt(const void *p
)
265 return (unsigned int) ((uintptr_t) p
);
269 #endif /* EGLDISPLAY_INCLUDED */