From 87f99e214a6f60c06cc34f844e02ecb0f63c953f Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 24 Jun 2009 18:34:06 +0100 Subject: [PATCH] [cogl-material] Be more carefull about flushing in cogl_material_remove_layer Previously we would call _cogl_material_pre_change_notify unconditionally, but now we wait until we really know we are removing a layer before notifying the change, which will require a journal flush. Since the convenience functions cogl_set_source_color4ub and cogl_set_source_texture share a single material, cogl_set_source_color4ub always calls cogl_material_remove_layer. Often this is a NOP though and shouldn't require a journal flush. This gets performance back to where it was before reverting the per-actor material commits. --- clutter/cogl/common/cogl-material.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/clutter/cogl/common/cogl-material.c b/clutter/cogl/common/cogl-material.c index 07a3236cd..453fd23cf 100644 --- a/clutter/cogl/common/cogl-material.c +++ b/clutter/cogl/common/cogl-material.c @@ -1026,20 +1026,26 @@ cogl_material_remove_layer (CoglHandle material_handle, CoglMaterial *material; CoglMaterialLayer *layer; GList *tmp; + gboolean notified_change = FALSE; g_return_if_fail (cogl_is_material (material_handle)); material = _cogl_material_pointer_from_handle (material_handle); - /* possibly flush primitives referencing the current state... */ - _cogl_material_pre_change_notify (material, FALSE, NULL); - for (tmp = material->layers; tmp != NULL; tmp = tmp->next) { layer = tmp->data; if (layer->index == layer_index) { CoglHandle handle = (CoglHandle) layer; + + /* possibly flush primitives referencing the current state... */ + if (!notified_change) + { + _cogl_material_pre_change_notify (material, FALSE, NULL); + notified_change = TRUE; + } + cogl_handle_unref (handle); material->layers = g_list_remove (material->layers, layer); material->n_layers--;