texture: Do some more validation in get_cogl_texture()

Check the layer type, even though right now we only have one type
available.
This commit is contained in:
Emmanuele Bassi 2010-09-06 17:50:57 +01:00
parent 7e56a98413
commit 128e981f6c

View File

@ -1306,7 +1306,6 @@ clutter_texture_set_cogl_material (ClutterTexture *texture,
cogl_handle_ref (cogl_material); cogl_handle_ref (cogl_material);
/* This */
if (texture->priv->material) if (texture->priv->material)
cogl_handle_unref (texture->priv->material); cogl_handle_unref (texture->priv->material);
@ -1341,16 +1340,24 @@ clutter_texture_set_cogl_material (ClutterTexture *texture,
CoglHandle CoglHandle
clutter_texture_get_cogl_texture (ClutterTexture *texture) clutter_texture_get_cogl_texture (ClutterTexture *texture)
{ {
CoglMaterialLayerType layer_type;
const GList *layers; const GList *layers;
int n_layers; int n_layers;
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_INVALID_HANDLE); g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_INVALID_HANDLE);
layers = cogl_material_get_layers (texture->priv->material); layers = cogl_material_get_layers (texture->priv->material);
if (layers == NULL)
return COGL_INVALID_HANDLE;
n_layers = g_list_length ((GList *)layers); n_layers = g_list_length ((GList *)layers);
if (n_layers == 0) if (n_layers == 0)
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
layer_type = cogl_material_layer_get_type (layers->data);
if (layer_type != COGL_MATERIAL_LAYER_TYPE_TEXTURE)
return COGL_INVALID_HANDLE;
return cogl_material_layer_get_texture (layers->data); return cogl_material_layer_get_texture (layers->data);
} }