summaryrefslogtreecommitdiff
path: root/cogl/cogl-gles2-context.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-09-10 11:26:17 +0100
committerRobert Bragg <robert@linux.intel.com>2012-09-17 23:06:20 +0100
commitea3d8eca9123594e696b0b8ee36db99d608830b9 (patch)
tree2a1766bb94771a31b6e1468e5fba4d3403853649 /cogl/cogl-gles2-context.c
parent2942fd362dab0bcfbd0bdc107339006a232cf91c (diff)
downloadcogl-ea3d8eca9123594e696b0b8ee36db99d608830b9.tar.gz
Don't take internal references on the context
We want applications to fully control the lifetime of a CoglContext without having to worry that internal resources (such as the default 2d,3d and rectangle textures, or any caches we maintain) could result in circular references that keep the context alive. We also want to avoid making CoglContext into a special kind of object that isn't ref-counted or that can't be used with object apis such as cogl_object_set_user_data. Being able to reliably destroy the context is important on platforms such as Android where you may be required bring-up and tear-down a CoglContext numerous times throughout the applications lifetime. A dissadvantage of this policy is that it is now possible to leave other object such as framebuffers in an inconsistent state if the context is unreferenced and destroyed. The documentation states that all objects that directly or indirectly depend on a context that has been destroyed will be left in an inconsistent state and must not be accessed thereafter. Applications (such as Android applications) that need to cleanly destroy and re-create Cogl resources should make sure to manually unref these dependant objects before destroying the context. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 23ce51beba1bb739a224e47614a59327dfbb65af)
Diffstat (limited to 'cogl/cogl-gles2-context.c')
-rw-r--r--cogl/cogl-gles2-context.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index 35857056..47f99b7c 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -1528,8 +1528,6 @@ _cogl_gles2_context_free (CoglGLES2Context *gles2_context)
NULL);
}
- cogl_object_unref (gles2_context->context);
-
g_free (gles2_context->vtable);
g_free (gles2_context);
@@ -1601,7 +1599,6 @@ cogl_gles2_context_new (CoglContext *ctx, GError **error)
gles2_ctx = g_malloc0 (sizeof (CoglGLES2Context));
- cogl_object_ref (ctx);
gles2_ctx->context = ctx;
COGL_LIST_INIT (&gles2_ctx->foreign_offscreens);
@@ -1610,7 +1607,6 @@ cogl_gles2_context_new (CoglContext *ctx, GError **error)
gles2_ctx->winsys = winsys->context_create_gles2_context (ctx, error);
if (gles2_ctx->winsys == NULL)
{
- cogl_object_unref (gles2_ctx->context);
g_free (gles2_ctx);
return NULL;
}