[cogl] egl: Make sure to free the underlying egl objects when the display is freed



commit d4dc51849e1e92f141fd71bf9c13c570db47a2f0
Author: Damien Lespiau <damien lespiau intel com>
Date:   Tue Jul 26 17:39:44 2011 +0300

    egl: Make sure to free the underlying egl objects when the display is freed
    
    If the display has been setup up, we should destroy the underlying
    objects that the winsys has created. This can be done by calling the
    winsys->destroy_display() function in _free.
    
    Then, in that function, and for the NULL and GDL EGL platform we can
    destroy the surface we have created in the setup_display() function
    (through create_context()).
    
    This allows to have clutter create a "dummy" display in
    cogl_renderer_check_onscreen_template(), then free it, then recreate the
    context and the surface that will be the final ones.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655355

 cogl/cogl-display.c           |   21 +++++++++++++++------
 cogl/winsys/cogl-winsys-egl.c |    9 ++++++++-
 2 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index ec13aa4..1c64fe9 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -49,9 +49,24 @@ cogl_display_error_quark (void)
   return g_quark_from_static_string ("cogl-display-error-quark");
 }
 
+static const CoglWinsysVtable *
+_cogl_display_get_winsys (CoglDisplay *display)
+{
+  return display->renderer->winsys_vtable;
+}
+
 static void
 _cogl_display_free (CoglDisplay *display)
 {
+  const CoglWinsysVtable *winsys;
+
+  if (display->setup)
+    {
+      winsys = _cogl_display_get_winsys (display);
+      winsys->display_destroy (display);
+      display->setup = FALSE;
+    }
+
   if (display->renderer)
     {
       cogl_object_unref (display->renderer);
@@ -104,12 +119,6 @@ cogl_display_new (CoglRenderer *renderer,
   return _cogl_display_object_new (display);
 }
 
-static const CoglWinsysVtable *
-_cogl_display_get_winsys (CoglDisplay *display)
-{
-  return display->renderer->winsys_vtable;
-}
-
 gboolean
 cogl_display_setup (CoglDisplay *display,
                     GError **error)
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 4ee208a..d4f83ac 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -953,7 +953,14 @@ cleanup_context (CoglDisplay *display)
       egl_display->egl_context = EGL_NO_CONTEXT;
     }
 
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
+#if defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
+    defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
+  if (egl_display->egl_surface != EGL_NO_SURFACE)
+    {
+      eglDestroySurface (egl_renderer->edpy, egl_display->egl_surface);
+      egl_display->egl_surface = EGL_NO_SURFACE;
+    }
+#elif COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
   if (egl_display->dummy_surface != EGL_NO_SURFACE)
     {
       eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]