1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
4 #include "egltypedefs.h"
5 #include "egldefines.h"
6 #include "eglsurface.h"
10 * Optional EGL extensions info.
12 struct _egl_extensions
14 EGLBoolean MESA_screen_surface
;
15 EGLBoolean MESA_copy_context
;
17 char String
[_EGL_MAX_EXTENSIONS_LEN
];
23 /* used to link displays */
26 EGLNativeDisplayType NativeDisplay
;
29 void *DriverData
; /* private to driver */
31 int APImajor
, APIminor
; /**< as returned by eglInitialize() */
32 char Version
[1000]; /**< initialized from APImajor/minor, DriverName */
34 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
35 EGLint ClientAPIsMask
;
36 char ClientAPIs
[1000]; /**< updated by eglQueryString */
38 _EGLExtensions Extensions
;
43 _EGLScreen
**Screens
; /* array [NumScreens] */
47 _EGLConfig
**Configs
; /* array [NumConfigs] of ptr to _EGLConfig */
49 /* lists of linked contexts and surface */
50 _EGLContext
*ContextList
;
51 _EGLSurface
*SurfaceList
;
56 _eglFiniDisplay(void);
60 _eglNewDisplay(NativeDisplayType displayName
);
64 _eglLinkDisplay(_EGLDisplay
*dpy
);
68 _eglUnlinkDisplay(_EGLDisplay
*dpy
);
72 _eglFindDisplay(NativeDisplayType nativeDisplay
);
76 _eglReleaseDisplayResources(_EGLDriver
*drv
, _EGLDisplay
*dpy
);
80 _eglCleanupDisplay(_EGLDisplay
*disp
);
84 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
);
88 _eglUnlinkSurface(_EGLSurface
*surf
);
91 #ifndef _EGL_SKIP_HANDLE_CHECK
95 _eglCheckDisplayHandle(EGLDisplay dpy
);
99 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
);
102 #else /* !_EGL_SKIP_HANDLE_CHECK */
104 /* Only do a quick check. This is NOT standard compliant. */
106 static INLINE EGLBoolean
107 _eglCheckDisplayHandle(EGLDisplay dpy
)
109 return ((_EGLDisplay
*) dpy
!= NULL
);
113 static INLINE EGLBoolean
114 _eglCheckSurfaceHandle(EGLSurface surf
, _EGLDisplay
*dpy
)
116 _EGLSurface
*s
= (_EGLSurface
*) surf
;
117 return (dpy
&& s
&& s
->Display
== dpy
);
121 #endif /* _EGL_SKIP_HANDLE_CHECK */
125 * Lookup a handle to find the linked display.
126 * Return NULL if the handle has no corresponding linked display.
128 static INLINE _EGLDisplay
*
129 _eglLookupDisplay(EGLDisplay display
)
131 _EGLDisplay
*dpy
= (_EGLDisplay
*) display
;
132 if (!_eglCheckDisplayHandle(display
))
139 * Return the handle of a linked display, or EGL_NO_DISPLAY.
141 static INLINE EGLDisplay
142 _eglGetDisplayHandle(_EGLDisplay
*dpy
)
144 return (EGLDisplay
) ((dpy
) ? dpy
: EGL_NO_DISPLAY
);
149 * Return true if the display is linked.
151 static INLINE EGLBoolean
152 _eglIsDisplayLinked(_EGLDisplay
*dpy
)
154 return (EGLBoolean
) (_eglGetDisplayHandle(dpy
) != EGL_NO_DISPLAY
);
159 * Lookup a handle to find the linked surface.
160 * Return NULL if the handle has no corresponding linked surface.
162 static INLINE _EGLSurface
*
163 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
165 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
166 if (!_eglCheckSurfaceHandle(surf
, dpy
))
173 * Return the handle of a linked surface, or EGL_NO_SURFACE.
175 static INLINE EGLSurface
176 _eglGetSurfaceHandle(_EGLSurface
*surf
)
178 return (EGLSurface
) ((surf
&& surf
->Display
) ? surf
: EGL_NO_SURFACE
);
183 * Return true if the surface is linked to a display.
185 static INLINE EGLBoolean
186 _eglIsSurfaceLinked(_EGLSurface
*surf
)
188 return (EGLBoolean
) (_eglGetSurfaceHandle(surf
) != EGL_NO_SURFACE
);
193 * Cast an unsigned int to a pointer.
196 _eglUIntToPointer(unsigned int v
)
198 return (void *) ((uintptr_t) v
);
203 * Cast a pointer to an unsigned int. The pointer must be one that is
204 * returned by _eglUIntToPointer.
206 static INLINE
unsigned int
207 _eglPointerToUInt(const void *p
)
209 return (unsigned int) ((uintptr_t) p
);
213 #endif /* EGLDISPLAY_INCLUDED */