[Cogl] [PATCH] auto-texture: revert _new_with_size semantics

Robert Bragg robert at sixbynine.org
Mon Sep 2 06:08:26 PDT 2013


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

This reverts the change in semantics for cogl_texture_new_with_size so
that it goes back to allocating textures synchronously and returning
NULL if there was a failure to allocate. Only the new/2.0 texture apis
will have the lazy allocation behaviour so we avoid breaking existing
code. This also fixes a potential crasher by removing a code path
that was passing NULL to cogl_texture_allocate() that would have caused
and abort if there were an error.
---
 cogl/cogl-auto-texture.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/cogl/cogl-auto-texture.c b/cogl/cogl-auto-texture.c
index cf65e79..3656213 100644
--- a/cogl/cogl-auto-texture.c
+++ b/cogl/cogl-auto-texture.c
@@ -109,14 +109,19 @@ cogl_texture_new_with_size (unsigned int width,
                                                                 internal_format));
     }
 
+  /* NB: This api existed before Cogl introduced lazy allocation of
+   * textures and so we maintain its original synchronous allocation
+   * semantics and return NULL if allocation fails... */
+  if (!cogl_texture_allocate (tex, &skip_error))
+    {
+      cogl_error_free (skip_error);
+      cogl_object-unref (tex);
+      return NULL;
+    }
+
   if (tex &&
       flags & COGL_TEXTURE_NO_AUTO_MIPMAP)
     {
-      /* To be able to iterate the slices of a #CoglTexture2DSliced we
-       * need to ensure the texture is allocated... */
-      if (!cogl_texture_allocate (tex, NULL))
-        return NULL;
-
       cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
                                            0, 0, 1, 1,
                                            COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
-- 
1.8.3.1



More information about the Cogl mailing list