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.
This commit is contained in:
Neil Roberts 2010-02-16 11:58:47 +00:00
parent 9e74b04fbd
commit 0238be686a

View File

@ -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;
}
else
{
/* We need to migrate the existing textures into a new texture */
new_tex =
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_PIXEL_FORMAT_RGBA_8888)) ==
COGL_INVALID_HANDLE)
{
COGL_NOTE (ATLAS, "Could not create a CoglTexture2D");
_cogl_atlas_free (new_atlas);
ret = FALSE;
}
else
{
COGL_NOTE (ATLAS,
"Atlas %s with size %ix%i",
ctx->atlas == NULL ||