static _EGL_DECLARE_MUTEX(_eglDisplayInitMutex);
static _EGLHashtable *_eglDisplayHash;
-/* TODO surface hash table should be per-display */
-static _EGLHashtable *_eglSurfaceHash;
/**
_eglDeleteHashTable(_eglDisplayHash);
_eglDisplayHash = NULL;
- _eglDeleteHashTable(_eglSurfaceHash);
- _eglSurfaceHash = NULL;
}
_eglUnlockMutex(&_eglDisplayInitMutex);
}
/* check again after acquiring lock */
if (!_eglDisplayHash) {
_eglDisplayHash = _eglNewHashTable();
- _eglSurfaceHash = _eglNewHashTable();
_eglAddAtExitCall(_eglFiniDisplay);
}
dpy->Xdpy = (Display *) nativeDisplay;
#endif
- _eglInitDisplay();
- dpy->SurfaceHash = _eglSurfaceHash;
-
dpy->DriverName = _eglPreloadDriver(dpy);
if (!dpy->DriverName) {
free(dpy);
EGLSurface
_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
{
- EGLuint key;
-
surf->Display = dpy;
surf->Next = dpy->SurfaceList;
dpy->SurfaceList = surf;
-
- key = _eglHashGenKey(dpy->SurfaceHash);
- assert(key);
- _eglHashInsert(dpy->SurfaceHash, key, surf);
-
- surf->Handle = (EGLSurface) _eglUIntToPointer(key);
- return surf->Handle;
+ return (EGLSurface) surf;
}
_eglUnlinkSurface(_EGLSurface *surf)
{
_EGLSurface *prev;
- EGLuint key = _eglPointerToUInt((void *) surf->Handle);
-
- _eglHashRemove(surf->Display->SurfaceHash, key);
- surf->Handle = EGL_NO_SURFACE;
prev = surf->Display->SurfaceList;
if (prev != surf) {
* Return the handle of a linked surface, or EGL_NO_SURFACE.
*/
EGLSurface
-_eglGetSurfaceHandle(_EGLSurface *surface)
+_eglGetSurfaceHandle(_EGLSurface *surf)
{
- if (surface)
- return surface->Handle;
- else
- return EGL_NO_SURFACE;
+ return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
}
* Return NULL if the handle has no corresponding linked surface.
*/
_EGLSurface *
-_eglLookupSurface(EGLSurface surf, _EGLDisplay *dpy)
+_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
{
- EGLuint key = _eglPointerToUInt((void *) surf);
- return (_EGLSurface *) _eglHashLookup(dpy->SurfaceHash, key);
+ _EGLSurface *surf = (_EGLSurface *) surface;
+ return (surf && surf->Display) ? surf : NULL;
}