egl: Use a boolean to indicate whether a resource is linked.
authorChia-I Wu <olvaffe@gmail.com>
Tue, 26 Jan 2010 07:16:49 +0000 (15:16 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 26 Jan 2010 10:46:05 +0000 (18:46 +0800)
An unlinked resource may still be a current resource such as current
surfaces.  There might still be a need to know which display the
unlinked resource belongs to.

src/egl/main/egldisplay.c
src/egl/main/egldisplay.h

index 359900c..125909d 100644 (file)
@@ -242,7 +242,10 @@ _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy)
 void
 _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy)
 {
+   assert(!res->Display || res->Display == dpy);
+
    res->Display = dpy;
+   res->IsLinked = EGL_TRUE;
    res->Next = dpy->ResourceLists[type];
    dpy->ResourceLists[type] = res;
 }
@@ -271,5 +274,6 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type)
    }
 
    res->Next = NULL;
-   res->Display = NULL;
+   /* do not reset res->Display */
+   res->IsLinked = EGL_FALSE;
 }
index 0f5d3a0..8f74ad2 100644 (file)
@@ -19,7 +19,11 @@ enum _egl_resource_type {
  */
 struct _egl_resource
 {
+   /* which display the resource belongs to */
    _EGLDisplay *Display;
+   EGLBoolean IsLinked;
+
+   /* used to link resources of the same type */
    _EGLResource *Next;
 };
 
@@ -179,7 +183,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
 static INLINE EGLBoolean
 _eglIsResourceLinked(_EGLResource *res)
 {
-   return (res->Display != NULL);
+   return res->IsLinked;
 }