From 52cbc93b1870b7734363024318603fbe67030126 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 20 May 2010 00:40:24 +0100 Subject: [PATCH] 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 --- cogl/cogl-material.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index 5c6b93b5a..d0f88f61d 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -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))