mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
egl: Add back handle checking.
Handle checking was done using hash tables. Now that they are gone, we have to loop over the lists. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
parent
e3734e4685
commit
e484a92928
2 changed files with 116 additions and 2 deletions
|
|
@ -275,3 +275,69 @@ _eglUnlinkSurface(_EGLSurface *surf)
|
|||
surf->Next = NULL;
|
||||
surf->Display = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifndef _EGL_SKIP_HANDLE_CHECK
|
||||
|
||||
|
||||
/**
|
||||
* Return EGL_TRUE if the given handle is a valid handle to a display.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglCheckDisplayHandle(EGLDisplay dpy)
|
||||
{
|
||||
_EGLDisplay *cur;
|
||||
|
||||
_eglLockMutex(_eglGlobal.Mutex);
|
||||
cur = _eglGlobal.DisplayList;
|
||||
while (cur) {
|
||||
if (cur == (_EGLDisplay *) dpy)
|
||||
break;
|
||||
cur = cur->Next;
|
||||
}
|
||||
_eglUnlockMutex(_eglGlobal.Mutex);
|
||||
return (cur != NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return EGL_TRUE if the given handle is a valid handle to a context.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLContext *cur;
|
||||
|
||||
cur = dpy->ContextList;
|
||||
while (cur) {
|
||||
if (cur == (_EGLContext *) ctx) {
|
||||
assert(cur->Display == dpy);
|
||||
break;
|
||||
}
|
||||
cur = cur->Next;
|
||||
}
|
||||
return (cur != NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return EGL_TRUE if the given handle is a valid handle to a surface.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLSurface *cur;
|
||||
|
||||
cur = dpy->SurfaceList;
|
||||
while (cur) {
|
||||
if (cur == (_EGLSurface *) surf) {
|
||||
assert(cur->Display == dpy);
|
||||
break;
|
||||
}
|
||||
cur = cur->Next;
|
||||
}
|
||||
return (cur != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* !_EGL_SKIP_HANDLE_CHECK */
|
||||
|
|
|
|||
|
|
@ -105,6 +105,48 @@ extern void
|
|||
_eglUnlinkSurface(_EGLSurface *surf);
|
||||
|
||||
|
||||
#ifndef _EGL_SKIP_HANDLE_CHECK
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglCheckDisplayHandle(EGLDisplay dpy);
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy);
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy);
|
||||
|
||||
|
||||
#else /* !_EGL_SKIP_HANDLE_CHECK */
|
||||
|
||||
/* Only do a quick check. This is NOT standard compliant. */
|
||||
|
||||
static INLINE EGLBoolean
|
||||
_eglCheckDisplayHandle(EGLDisplay dpy) { return EGL_TRUE; }
|
||||
|
||||
|
||||
static INLINE EGLBoolean
|
||||
_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLContext *c = (_EGLContext *) ctx;
|
||||
return (c && c->Display == dpy);
|
||||
}
|
||||
|
||||
|
||||
static INLINE EGLBoolean
|
||||
_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLSurface *s = (_EGLSurface *) surf;
|
||||
return (s && s->Display == dpy);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _EGL_SKIP_HANDLE_CHECK */
|
||||
|
||||
|
||||
/**
|
||||
* Lookup a handle to find the linked display.
|
||||
* Return NULL if the handle has no corresponding linked display.
|
||||
|
|
@ -113,6 +155,8 @@ static INLINE _EGLDisplay *
|
|||
_eglLookupDisplay(EGLDisplay display)
|
||||
{
|
||||
_EGLDisplay *dpy = (_EGLDisplay *) display;
|
||||
if (!_eglCheckDisplayHandle(display))
|
||||
dpy = NULL;
|
||||
return dpy;
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +189,9 @@ static INLINE _EGLContext *
|
|||
_eglLookupContext(EGLContext context, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLContext *ctx = (_EGLContext *) context;
|
||||
return (ctx && ctx->Display) ? ctx : NULL;
|
||||
if (!_eglCheckContextHandle(context, dpy))
|
||||
ctx = NULL;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -177,7 +223,9 @@ static INLINE _EGLSurface *
|
|||
_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLSurface *surf = (_EGLSurface *) surface;
|
||||
return (surf && surf->Display) ? surf : NULL;
|
||||
if (!_eglCheckSurfaceHandle(surf, dpy))
|
||||
surf = NULL;
|
||||
return surf;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue