From a5021ba30f553d641399545d9777eb5b4b385ac1 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 16 Feb 2010 11:58:47 +0000 Subject: [PATCH] cogl-atlas-texture: Check for errors when creating the atlas texture cogl_texture_2d_new may fail in certain circumstances so cogl_atlas_texture_reserve_space should detect this and also fail. This will cause cogl_texture_new to fallback to a sliced texture. Thanks to Vladimir Ivakin for reporting this problem. --- clutter/cogl/cogl/cogl-atlas-texture.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/clutter/cogl/cogl/cogl-atlas-texture.c b/clutter/cogl/cogl/cogl-atlas-texture.c index 7cb7684b8..35cc9861c 100644 --- a/clutter/cogl/cogl/cogl-atlas-texture.c +++ b/clutter/cogl/cogl/cogl-atlas-texture.c @@ -861,15 +861,20 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex, COGL_NOTE (ATLAS, "Could not fit texture in the atlas"); ret = FALSE; } + /* We need to migrate the existing textures into a new texture */ + else if ((new_tex = + _cogl_texture_2d_new_with_size (_cogl_atlas_get_width (new_atlas), + _cogl_atlas_get_height (new_atlas), + COGL_TEXTURE_NONE, + COGL_PIXEL_FORMAT_RGBA_8888)) == + COGL_INVALID_HANDLE) + { + COGL_NOTE (ATLAS, "Could not create a CoglTexture2D"); + _cogl_atlas_free (new_atlas); + ret = FALSE; + } else { - /* We need to migrate the existing textures into a new texture */ - new_tex = - _cogl_texture_2d_new_with_size (_cogl_atlas_get_width (new_atlas), - _cogl_atlas_get_height (new_atlas), - COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_RGBA_8888); - COGL_NOTE (ATLAS, "Atlas %s with size %ix%i", ctx->atlas == NULL ||