egl: Remove hash table for surfaces.
The hash table was used to map a surface to a handle. It is simpler to cast directly. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
static _EGL_DECLARE_MUTEX(_eglDisplayInitMutex);
|
static _EGL_DECLARE_MUTEX(_eglDisplayInitMutex);
|
||||||
static _EGLHashtable *_eglDisplayHash;
|
static _EGLHashtable *_eglDisplayHash;
|
||||||
/* TODO surface hash table should be per-display */
|
|
||||||
static _EGLHashtable *_eglSurfaceHash;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,8 +45,6 @@ _eglFiniDisplay(void)
|
|||||||
|
|
||||||
_eglDeleteHashTable(_eglDisplayHash);
|
_eglDeleteHashTable(_eglDisplayHash);
|
||||||
_eglDisplayHash = NULL;
|
_eglDisplayHash = NULL;
|
||||||
_eglDeleteHashTable(_eglSurfaceHash);
|
|
||||||
_eglSurfaceHash = NULL;
|
|
||||||
}
|
}
|
||||||
_eglUnlockMutex(&_eglDisplayInitMutex);
|
_eglUnlockMutex(&_eglDisplayInitMutex);
|
||||||
}
|
}
|
||||||
@@ -64,7 +60,6 @@ _eglInitDisplay(void)
|
|||||||
/* check again after acquiring lock */
|
/* check again after acquiring lock */
|
||||||
if (!_eglDisplayHash) {
|
if (!_eglDisplayHash) {
|
||||||
_eglDisplayHash = _eglNewHashTable();
|
_eglDisplayHash = _eglNewHashTable();
|
||||||
_eglSurfaceHash = _eglNewHashTable();
|
|
||||||
|
|
||||||
_eglAddAtExitCall(_eglFiniDisplay);
|
_eglAddAtExitCall(_eglFiniDisplay);
|
||||||
}
|
}
|
||||||
@@ -90,9 +85,6 @@ _eglNewDisplay(NativeDisplayType nativeDisplay)
|
|||||||
dpy->Xdpy = (Display *) nativeDisplay;
|
dpy->Xdpy = (Display *) nativeDisplay;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_eglInitDisplay();
|
|
||||||
dpy->SurfaceHash = _eglSurfaceHash;
|
|
||||||
|
|
||||||
dpy->DriverName = _eglPreloadDriver(dpy);
|
dpy->DriverName = _eglPreloadDriver(dpy);
|
||||||
if (!dpy->DriverName) {
|
if (!dpy->DriverName) {
|
||||||
free(dpy);
|
free(dpy);
|
||||||
@@ -319,18 +311,10 @@ _eglLookupContext(EGLContext ctx, _EGLDisplay *dpy)
|
|||||||
EGLSurface
|
EGLSurface
|
||||||
_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
|
_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
|
||||||
{
|
{
|
||||||
EGLuint key;
|
|
||||||
|
|
||||||
surf->Display = dpy;
|
surf->Display = dpy;
|
||||||
surf->Next = dpy->SurfaceList;
|
surf->Next = dpy->SurfaceList;
|
||||||
dpy->SurfaceList = surf;
|
dpy->SurfaceList = surf;
|
||||||
|
return (EGLSurface) surf;
|
||||||
key = _eglHashGenKey(dpy->SurfaceHash);
|
|
||||||
assert(key);
|
|
||||||
_eglHashInsert(dpy->SurfaceHash, key, surf);
|
|
||||||
|
|
||||||
surf->Handle = (EGLSurface) _eglUIntToPointer(key);
|
|
||||||
return surf->Handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,10 +326,6 @@ void
|
|||||||
_eglUnlinkSurface(_EGLSurface *surf)
|
_eglUnlinkSurface(_EGLSurface *surf)
|
||||||
{
|
{
|
||||||
_EGLSurface *prev;
|
_EGLSurface *prev;
|
||||||
EGLuint key = _eglPointerToUInt((void *) surf->Handle);
|
|
||||||
|
|
||||||
_eglHashRemove(surf->Display->SurfaceHash, key);
|
|
||||||
surf->Handle = EGL_NO_SURFACE;
|
|
||||||
|
|
||||||
prev = surf->Display->SurfaceList;
|
prev = surf->Display->SurfaceList;
|
||||||
if (prev != surf) {
|
if (prev != surf) {
|
||||||
@@ -371,12 +351,9 @@ _eglUnlinkSurface(_EGLSurface *surf)
|
|||||||
* Return the handle of a linked surface, or EGL_NO_SURFACE.
|
* Return the handle of a linked surface, or EGL_NO_SURFACE.
|
||||||
*/
|
*/
|
||||||
EGLSurface
|
EGLSurface
|
||||||
_eglGetSurfaceHandle(_EGLSurface *surface)
|
_eglGetSurfaceHandle(_EGLSurface *surf)
|
||||||
{
|
{
|
||||||
if (surface)
|
return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
|
||||||
return surface->Handle;
|
|
||||||
else
|
|
||||||
return EGL_NO_SURFACE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -385,8 +362,8 @@ _eglGetSurfaceHandle(_EGLSurface *surface)
|
|||||||
* Return NULL if the handle has no corresponding linked surface.
|
* Return NULL if the handle has no corresponding linked surface.
|
||||||
*/
|
*/
|
||||||
_EGLSurface *
|
_EGLSurface *
|
||||||
_eglLookupSurface(EGLSurface surf, _EGLDisplay *dpy)
|
_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
|
||||||
{
|
{
|
||||||
EGLuint key = _eglPointerToUInt((void *) surf);
|
_EGLSurface *surf = (_EGLSurface *) surface;
|
||||||
return (_EGLSurface *) _eglHashLookup(dpy->SurfaceHash, key);
|
return (surf && surf->Display) ? surf : NULL;
|
||||||
}
|
}
|
||||||
|
@@ -52,9 +52,6 @@ struct _egl_display
|
|||||||
_EGLContext *ContextList;
|
_EGLContext *ContextList;
|
||||||
_EGLSurface *SurfaceList;
|
_EGLSurface *SurfaceList;
|
||||||
|
|
||||||
/* hash table to map surfaces to handles */
|
|
||||||
_EGLHashtable *SurfaceHash;
|
|
||||||
|
|
||||||
#ifdef _EGL_PLATFORM_X
|
#ifdef _EGL_PLATFORM_X
|
||||||
Display *Xdpy;
|
Display *Xdpy;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -13,7 +13,6 @@ struct _egl_surface
|
|||||||
/* Managed by EGLDisplay for linking */
|
/* Managed by EGLDisplay for linking */
|
||||||
_EGLDisplay *Display;
|
_EGLDisplay *Display;
|
||||||
_EGLSurface *Next;
|
_EGLSurface *Next;
|
||||||
EGLSurface Handle;
|
|
||||||
|
|
||||||
/* The bound status of the surface */
|
/* The bound status of the surface */
|
||||||
_EGLContext *Binding;
|
_EGLContext *Binding;
|
||||||
|
Reference in New Issue
Block a user