egldisplay.h revision 4a49301e
10d16fef4Smrg#ifndef EGLDISPLAY_INCLUDED 20d16fef4Smrg#define EGLDISPLAY_INCLUDED 30d16fef4Smrg 40d16fef4Smrg#include "egltypedefs.h" 50d16fef4Smrg#include "egldefines.h" 60d16fef4Smrg#include "eglcontext.h" 70d16fef4Smrg#include "eglsurface.h" 80d16fef4Smrg 90d16fef4Smrg 100d16fef4Smrg/** 110d16fef4Smrg * Optional EGL extensions info. 120d16fef4Smrg */ 130d16fef4Smrgstruct _egl_extensions 140d16fef4Smrg{ 150d16fef4Smrg EGLBoolean MESA_screen_surface; 160d16fef4Smrg EGLBoolean MESA_copy_context; 170d16fef4Smrg 180d16fef4Smrg char String[_EGL_MAX_EXTENSIONS_LEN]; 190d16fef4Smrg}; 200d16fef4Smrg 210d16fef4Smrg 220d16fef4Smrgstruct _egl_display 230d16fef4Smrg{ 240d16fef4Smrg /* used to link displays */ 250d16fef4Smrg _EGLDisplay *Next; 260d16fef4Smrg 270d16fef4Smrg EGLNativeDisplayType NativeDisplay; 280d16fef4Smrg 290d16fef4Smrg const char *DriverName; 300d16fef4Smrg _EGLDriver *Driver; 310d16fef4Smrg void *DriverData; /* private to driver */ 320d16fef4Smrg 330d16fef4Smrg int APImajor, APIminor; /**< as returned by eglInitialize() */ 340d16fef4Smrg char Version[1000]; /**< initialized from APImajor/minor, DriverName */ 350d16fef4Smrg 360d16fef4Smrg /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ 370d16fef4Smrg EGLint ClientAPIsMask; 380d16fef4Smrg char ClientAPIs[1000]; /**< updated by eglQueryString */ 390d16fef4Smrg 400d16fef4Smrg _EGLExtensions Extensions; 410d16fef4Smrg 420d16fef4Smrg int LargestPbuffer; 430d16fef4Smrg 440d16fef4Smrg EGLint NumScreens; 450d16fef4Smrg _EGLScreen **Screens; /* array [NumScreens] */ 460d16fef4Smrg 470d16fef4Smrg EGLint MaxConfigs; 480d16fef4Smrg EGLint NumConfigs; 490d16fef4Smrg _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */ 500d16fef4Smrg 510d16fef4Smrg /* lists of linked contexts and surface */ 520d16fef4Smrg _EGLContext *ContextList; 530d16fef4Smrg _EGLSurface *SurfaceList; 540d16fef4Smrg}; 55 56 57extern void 58_eglFiniDisplay(void); 59 60 61extern char * 62_eglSplitDisplayString(const char *dpyString, const char **args); 63 64 65extern _EGLDisplay * 66_eglNewDisplay(NativeDisplayType displayName); 67 68 69extern EGLDisplay 70_eglLinkDisplay(_EGLDisplay *dpy); 71 72 73extern void 74_eglUnlinkDisplay(_EGLDisplay *dpy); 75 76 77extern _EGLDisplay * 78_eglFindDisplay(NativeDisplayType nativeDisplay); 79 80 81extern void 82_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy); 83 84 85extern void 86_eglCleanupDisplay(_EGLDisplay *disp); 87 88 89extern EGLContext 90_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy); 91 92 93extern void 94_eglUnlinkContext(_EGLContext *ctx); 95 96 97extern EGLSurface 98_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); 99 100 101extern void 102_eglUnlinkSurface(_EGLSurface *surf); 103 104 105#ifndef _EGL_SKIP_HANDLE_CHECK 106 107 108extern EGLBoolean 109_eglCheckDisplayHandle(EGLDisplay dpy); 110 111 112extern EGLBoolean 113_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy); 114 115 116extern EGLBoolean 117_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy); 118 119 120#else /* !_EGL_SKIP_HANDLE_CHECK */ 121 122/* Only do a quick check. This is NOT standard compliant. */ 123 124static INLINE EGLBoolean 125_eglCheckDisplayHandle(EGLDisplay dpy) 126{ 127 return ((_EGLDisplay *) dpy != NULL); 128} 129 130 131static INLINE EGLBoolean 132_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) 133{ 134 _EGLContext *c = (_EGLContext *) ctx; 135 return (dpy && c && c->Display == dpy); 136} 137 138 139static INLINE EGLBoolean 140_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) 141{ 142 _EGLSurface *s = (_EGLSurface *) surf; 143 return (dpy && s && s->Display == dpy); 144} 145 146 147#endif /* _EGL_SKIP_HANDLE_CHECK */ 148 149 150/** 151 * Lookup a handle to find the linked display. 152 * Return NULL if the handle has no corresponding linked display. 153 */ 154static INLINE _EGLDisplay * 155_eglLookupDisplay(EGLDisplay display) 156{ 157 _EGLDisplay *dpy = (_EGLDisplay *) display; 158 if (!_eglCheckDisplayHandle(display)) 159 dpy = NULL; 160 return dpy; 161} 162 163 164/** 165 * Return the handle of a linked display, or EGL_NO_DISPLAY. 166 */ 167static INLINE EGLDisplay 168_eglGetDisplayHandle(_EGLDisplay *dpy) 169{ 170 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY); 171} 172 173 174/** 175 * Return true if the display is linked. 176 */ 177static INLINE EGLBoolean 178_eglIsDisplayLinked(_EGLDisplay *dpy) 179{ 180 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY); 181} 182 183 184/** 185 * Lookup a handle to find the linked context. 186 * Return NULL if the handle has no corresponding linked context. 187 */ 188static INLINE _EGLContext * 189_eglLookupContext(EGLContext context, _EGLDisplay *dpy) 190{ 191 _EGLContext *ctx = (_EGLContext *) context; 192 if (!_eglCheckContextHandle(context, dpy)) 193 ctx = NULL; 194 return ctx; 195} 196 197 198/** 199 * Return the handle of a linked context, or EGL_NO_CONTEXT. 200 */ 201static INLINE EGLContext 202_eglGetContextHandle(_EGLContext *ctx) 203{ 204 return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); 205} 206 207 208/** 209 * Return true if the context is linked to a display. 210 */ 211static INLINE EGLBoolean 212_eglIsContextLinked(_EGLContext *ctx) 213{ 214 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); 215} 216 217 218/** 219 * Lookup a handle to find the linked surface. 220 * Return NULL if the handle has no corresponding linked surface. 221 */ 222static INLINE _EGLSurface * 223_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) 224{ 225 _EGLSurface *surf = (_EGLSurface *) surface; 226 if (!_eglCheckSurfaceHandle(surf, dpy)) 227 surf = NULL; 228 return surf; 229} 230 231 232/** 233 * Return the handle of a linked surface, or EGL_NO_SURFACE. 234 */ 235static INLINE EGLSurface 236_eglGetSurfaceHandle(_EGLSurface *surf) 237{ 238 return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE); 239} 240 241 242/** 243 * Return true if the surface is linked to a display. 244 */ 245static INLINE EGLBoolean 246_eglIsSurfaceLinked(_EGLSurface *surf) 247{ 248 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE); 249} 250 251 252/** 253 * Cast an unsigned int to a pointer. 254 */ 255static INLINE void * 256_eglUIntToPointer(unsigned int v) 257{ 258 return (void *) ((uintptr_t) v); 259} 260 261 262/** 263 * Cast a pointer to an unsigned int. The pointer must be one that is 264 * returned by _eglUIntToPointer. 265 */ 266static INLINE unsigned int 267_eglPointerToUInt(const void *p) 268{ 269 return (unsigned int) ((uintptr_t) p); 270} 271 272 273#endif /* EGLDISPLAY_INCLUDED */ 274