egl: Destroy display's resources upon termination.
authorChia-I Wu <olvaffe@gmail.com>
Fri, 17 Jul 2009 04:21:57 +0000 (21:21 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 17 Jul 2009 17:54:06 +0000 (11:54 -0600)
eglTerminate should destroy the contexts and surfaces of the display.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/egl/main/egldisplay.c
src/egl/main/egldisplay.h
src/egl/main/egldriver.c

index 1f1f41ea71f769a48c1eaa692eef2fdbb7a9084c..89de609d0b46e6e8077f1e6501b6ec27af2cbde6 100644 (file)
@@ -120,6 +120,38 @@ _eglFindDisplay(NativeDisplayType nativeDisplay)
 }
 
 
+/**
+ * Destroy the contexts and surfaces that are linked to the display.
+ */
+void
+_eglReleaseDisplayResources(_EGLDriver *drv, EGLDisplay dpy)
+{
+   _EGLDisplay *display;
+   _EGLContext *contexts;
+   _EGLSurface *surfaces;
+
+   display = _eglLookupDisplay(dpy);
+   if (!display)
+      return;
+   contexts = display->ContextList;
+   surfaces = display->SurfaceList;
+
+   while (contexts) {
+      EGLContext handle = _eglGetContextHandle(contexts);
+      contexts = contexts->Next;
+      drv->API.DestroyContext(drv, dpy, handle);
+   }
+   assert(!display->ContextList);
+
+   while (surfaces) {
+      EGLSurface handle = _eglGetSurfaceHandle(surfaces);
+      surfaces = surfaces->Next;
+      drv->API.DestroySurface(drv, dpy, handle);
+   }
+   assert(!display->SurfaceList);
+}
+
+
 /**
  * Free all the data hanging of an _EGLDisplay object, but not
  * the object itself.
index 0a6003f39eafcdbea727a0d6fc83eef00513fa2b..30b466cb4a08ba7658098a87313b7c2e68b329b8 100644 (file)
@@ -56,6 +56,10 @@ extern _EGLDisplay *
 _eglFindDisplay(NativeDisplayType nativeDisplay);
 
 
+extern void
+_eglReleaseDisplayResources(_EGLDriver *drv, EGLDisplay dpy);
+
+
 extern void
 _eglCleanupDisplay(_EGLDisplay *disp);
 
index 43b1f519034b75793ce120d00b328bc7e767857f..f2a864cd8a705f50ce45178a99636495c771a310 100644 (file)
@@ -284,9 +284,7 @@ _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy)
 
    _eglLog(_EGL_DEBUG, "Closing %s", drv->Name);
 
-   /*
-    * XXX check for currently bound context/surfaces and delete them?
-    */
+   _eglReleaseDisplayResources(drv, dpy);
 
    b = drv->API.Terminate(drv, dpy);