From 32486fe995911256a76673bf62609312893281be Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 24 Jan 2011 18:42:28 +0000 Subject: [PATCH] pipeline: fix for _init_multi_property_sparse_state When copying COMBINE state in _cogl_pipeline_layer_init_multi_property_sparse_state we would read some state from the destination layer (invalid data potentially), then redundantly set the value back on the destination. This was picked up by valgrind, and the code is now more careful about how it references the src layer vs the destination layer. --- clutter/cogl/cogl/cogl-pipeline.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/clutter/cogl/cogl/cogl-pipeline.c b/clutter/cogl/cogl/cogl-pipeline.c index 24f304676..83f0c4bbc 100644 --- a/clutter/cogl/cogl/cogl-pipeline.c +++ b/clutter/cogl/cogl/cogl-pipeline.c @@ -1745,28 +1745,29 @@ _cogl_pipeline_layer_init_multi_property_sparse_state ( { int n_args; int i; - CoglPipelineLayerBigState *big_state = layer->big_state; - GLint func = big_state->texture_combine_rgb_func; + CoglPipelineLayerBigState *src_big_state = authority->big_state; + CoglPipelineLayerBigState *dest_big_state = layer->big_state; + GLint func = src_big_state->texture_combine_rgb_func; - big_state->texture_combine_rgb_func = func; + dest_big_state->texture_combine_rgb_func = func; n_args = _cogl_get_n_args_for_combine_func (func); for (i = 0; i < n_args; i++) { - big_state->texture_combine_rgb_src[i] = - authority->big_state->texture_combine_rgb_src[i]; - big_state->texture_combine_rgb_op[i] = - authority->big_state->texture_combine_rgb_op[i]; + dest_big_state->texture_combine_rgb_src[i] = + src_big_state->texture_combine_rgb_src[i]; + dest_big_state->texture_combine_rgb_op[i] = + src_big_state->texture_combine_rgb_op[i]; } - func = authority->big_state->texture_combine_alpha_func; - big_state->texture_combine_alpha_func = func; + func = src_big_state->texture_combine_alpha_func; + dest_big_state->texture_combine_alpha_func = func; n_args = _cogl_get_n_args_for_combine_func (func); for (i = 0; i < n_args; i++) { - big_state->texture_combine_alpha_src[i] = - authority->big_state->texture_combine_alpha_src[i]; - big_state->texture_combine_alpha_op[i] = - authority->big_state->texture_combine_alpha_op[i]; + dest_big_state->texture_combine_alpha_src[i] = + src_big_state->texture_combine_alpha_src[i]; + dest_big_state->texture_combine_alpha_op[i] = + src_big_state->texture_combine_alpha_op[i]; } break; }