1
0
Fork 0

cogl-material: Fix the count of the number of layers

Previously the counter for the number of layers was only updated
whenever the texture handle for a layer changes. However there are
many other ways for a new layer to be created for example by setting a
layer combine constant. Also by default the texture on a layer is
COGL_INVALID_HANDLE so if the application tries to create an explicit
layer with no texture by calling cogl_material_set_layer with
COGL_INVALID_HANDLE then it also wouldn't update the count.

This patch fixes that by incrementing the count in
cogl_material_get_layer instead. This function is called by all
functions that may end up creating a layer so it seems like the most
appropriate place.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
This commit is contained in:
Neil Roberts 2010-05-20 00:40:24 +01:00
parent 992d5f7fb6
commit 52cbc93b18

View file

@ -799,6 +799,8 @@ _cogl_material_get_layer (CoglMaterial *material,
material->layers =
g_list_insert_before (material->layers, tmp, layer_handle);
material->n_layers++;
return layer;
}
@ -824,7 +826,6 @@ cogl_material_set_layer (CoglHandle material_handle,
/* possibly flush primitives referencing the current state... */
_cogl_material_pre_change_notify (material, FALSE, NULL);
material->n_layers = g_list_length (material->layers);
if (material->n_layers > _cogl_get_max_texture_image_units ())
{
if (!(material->flags & COGL_MATERIAL_FLAG_SHOWN_SAMPLER_WARNING))