[cogl/cogl-1.16] auto-texture: revert _new_with_size semantics



commit 8ae53cea08c1dd151ab2b5c950f0ba2c314deb89
Author: Robert Bragg <robert sixbynine org>
Date:   Mon Sep 2 14:16:37 2013 +0100

    auto-texture: revert _new_with_size semantics
    
    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.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-auto-texture.c |   15 ++++++++++-----
 cogl/cogl-texture.h      |    9 +--------
 2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/cogl/cogl-auto-texture.c b/cogl/cogl-auto-texture.c
index cf65e79..b92212d 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,
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index 6f304ab..4678884 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -112,14 +112,7 @@ uint32_t cogl_texture_error_quark (void);
  *
  * Creates a new #CoglTexture with the specified dimensions and pixel format.
  *
- * The storage for the texture is not necesarily created before this
- * function returns. The storage can be explicitly allocated using
- * cogl_texture_allocate() or preferably you can let Cogl
- * automatically allocate the storage lazily when uploading data when
- * Cogl may know more about how the texture will be used and can
- * optimize how it is allocated.
- *
- * Return value: A newly created #CoglTexture
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 0.8
  */


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