From 1314d0b1a7567efd89f0aeca94a1d3e4c6b392bb Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sun, 8 Aug 2010 13:54:07 +0100 Subject: [PATCH] material: chain up in layer_pre_change_notify A change to a layer is also going to be a change to its owning material so we have to chain up in _cogl_material_layer_pre_change_notify and call _cogl_material_pre_change_notify. Previously we were only considering if the owning material was referenced in the journal but that ignores that it might also have dependants. We no longer need to flush the journal directly in layer_pre_change_notify. --- clutter/cogl/cogl/cogl-material.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 8f4e1bd61..58aa2e13d 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -1444,8 +1444,19 @@ _cogl_material_layer_pre_change_notify (CoglMaterial *required_owner, /* We only allow a NULL required_owner for new layers */ g_return_val_if_fail (required_owner != NULL, layer); + /* Chain up: + * A modification of a layer is indirectly also a modification of + * its owner so first make sure to flush the journal of any + * references to the current owner state and if necessary perform + * a copy-on-write for the required_owner if it has dependants. + */ + _cogl_material_pre_change_notify (required_owner, + COGL_MATERIAL_STATE_LAYERS, + NULL); + /* Unlike materials; layers are simply considered immutable once - * they have dependants - either children or another material owner. + * they have dependants - either direct children, or another + * material as an owner. */ if (COGL_MATERIAL_NODE (layer)->has_children || layer->owner != required_owner) @@ -1463,9 +1474,6 @@ _cogl_material_layer_pre_change_notify (CoglMaterial *required_owner, * this layer (required_owner), and there are no other layers * dependant on this layer so it's ok to modify it. */ - if (required_owner->journal_ref_count) - _cogl_journal_flush (); - _cogl_material_backend_layer_change_notify (layer, change); /* If the layer being changed is the same as the last layer we