[Cogl] [PATCH] context: Simplify _cogl_context_get_default

Robert Bragg robert at sixbynine.org
Mon Sep 10 04:01:59 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

Since the 2.0 api requires developers to explicitly create a CoglContext
we no longer need to be able to create a context lazily in
_cogl_context_get_default() so the function can simply be reduced to an
assertion that a context has been created and return the file scope
_cogl_context pointer.
---
 cogl/cogl-context.c |   14 +-------------
 1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index b032ef4..19e23c6 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -527,19 +527,7 @@ _cogl_context_free (CoglContext *context)
 CoglContext *
 _cogl_context_get_default (void)
 {
-  CoglError *error = NULL;
-  /* Create if doesn't exist yet */
-  if (_cogl_context == NULL)
-    {
-      _cogl_context = cogl_context_new (NULL, &error);
-      if (!_cogl_context)
-        {
-          g_warning ("Failed to create default context: %s",
-                     error->message);
-          cogl_error_free (error);
-        }
-    }
-
+  _COGL_RETURN_VAL_IF_FAIL (_cogl_context != NULL, NULL);
   return _cogl_context;
 }
 
-- 
1.7.7.6



More information about the Cogl mailing list