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>
This commit is contained in:
Robert Bragg 2013-09-02 14:16:37 +01:00 committed by Neil Roberts
parent 08fecbaa84
commit 8ae53cea08
2 changed files with 11 additions and 13 deletions

View File

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

View File

@ -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
*/