mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
texture: Add more validation on the material
If set_cogl_texture() is called after unsetting the Texture's material then we really want to make a copy of the template. Also, we should assert more often if the internal state goes horribly wrong: at least, we'll have a backtrace.
This commit is contained in:
parent
66104f5112
commit
7fe0df393b
@ -1271,6 +1271,7 @@ clutter_texture_init (ClutterTexture *self)
|
|||||||
cogl_handle_unref (dummy_tex);
|
cogl_handle_unref (dummy_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_assert (texture_template_material != NULL);
|
||||||
priv->material = cogl_material_copy (texture_template_material);
|
priv->material = cogl_material_copy (texture_template_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1356,13 +1357,16 @@ clutter_texture_set_cogl_material (ClutterTexture *texture,
|
|||||||
CoglHandle
|
CoglHandle
|
||||||
clutter_texture_get_cogl_texture (ClutterTexture *texture)
|
clutter_texture_get_cogl_texture (ClutterTexture *texture)
|
||||||
{
|
{
|
||||||
|
ClutterTexturePrivate *priv;
|
||||||
CoglMaterialLayerType layer_type;
|
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);
|
priv = texture->priv;
|
||||||
|
|
||||||
|
layers = cogl_material_get_layers (priv->material);
|
||||||
if (layers == NULL)
|
if (layers == NULL)
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
@ -1421,6 +1425,10 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture,
|
|||||||
texture_free_gl_resources (texture);
|
texture_free_gl_resources (texture);
|
||||||
|
|
||||||
/* Use the new texture */
|
/* Use the new texture */
|
||||||
|
if (priv->material == NULL)
|
||||||
|
priv->material = cogl_material_copy (texture_template_material);
|
||||||
|
|
||||||
|
g_assert (priv->material != NULL);
|
||||||
cogl_material_set_layer (priv->material, 0, cogl_tex);
|
cogl_material_set_layer (priv->material, 0, cogl_tex);
|
||||||
|
|
||||||
/* The material now holds a reference to the texture so we can
|
/* The material now holds a reference to the texture so we can
|
||||||
|
Loading…
Reference in New Issue
Block a user