From 7abf42626fe8552cf898652134f3767e591614ab Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:30:04 +0800 Subject: egl: Add _EGLResource and _EGLResourceType. Resources are objects managed by a display. They can be linked to or unlinked from a display. It is also possible to check if a resource is valid. --- src/egl/main/egldisplay.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/egl/main/egldisplay.c') diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 79efa8477e..ef144f7f07 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -205,4 +205,64 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } +/** + * Return EGL_TRUE if the given resource is valid. That is, the display does + * own the resource. + */ +EGLBoolean +_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +{ + _EGLResource *list = dpy->ResourceLists[type]; + + while (list) { + if (res == list) { + assert(list->Display == dpy); + break; + } + list = list->Next; + } + + return (list != NULL); +} + + #endif /* !_EGL_SKIP_HANDLE_CHECK */ + + +/** + * Link a resource to a display. + */ +void +_eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +{ + res->Display = dpy; + res->Next = dpy->ResourceLists[type]; + dpy->ResourceLists[type] = res; +} + + +/** + * Unlink a linked resource from its display. + */ +void +_eglUnlinkResource(_EGLResource *res, _EGLResourceType type) +{ + _EGLResource *prev; + + prev = res->Display->ResourceLists[type]; + if (prev != res) { + while (prev) { + if (prev->Next == res) + break; + prev = prev->Next; + } + assert(prev); + prev->Next = res->Next; + } + else { + res->Display->ResourceLists[type] = res->Next; + } + + res->Next = NULL; + res->Display = NULL; +} -- cgit v1.2.3