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
This commit is contained in:
Damien Lespiau 2011-07-26 17:39:44 +03:00
parent 2c3827aced
commit d4dc51849e
2 changed files with 23 additions and 7 deletions

View File

@ -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)

View File

@ -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);