mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 16:16:20 -05:00
cogl-pipeline: Fix comparing the color in set_layer_combine_constant
In cogl_pipeline_set_layer_combine_constant it was comparing whether the new color is the same as the old color using a memcmp on the constant_color parameter. However the combine constant is stored in the layer data as an array of four floats but the passed in color is a CoglColor (which is currently an array of four guint8s). This was causing valgrind errors and presumably also the check for setting the same color twice would always fail. This patch makes it do the conversion to a float array upfront before the comparison.
This commit is contained in:
parent
a573ad05c9
commit
5740a5a38a
@ -5264,6 +5264,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
|
|||||||
CoglPipelineLayer *layer;
|
CoglPipelineLayer *layer;
|
||||||
CoglPipelineLayer *authority;
|
CoglPipelineLayer *authority;
|
||||||
CoglPipelineLayer *new;
|
CoglPipelineLayer *new;
|
||||||
|
float color_as_floats[4];
|
||||||
|
|
||||||
g_return_if_fail (cogl_is_pipeline (pipeline));
|
g_return_if_fail (cogl_is_pipeline (pipeline));
|
||||||
|
|
||||||
@ -5279,8 +5280,13 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
|
|||||||
* state we want to change */
|
* state we want to change */
|
||||||
authority = _cogl_pipeline_layer_get_authority (layer, state);
|
authority = _cogl_pipeline_layer_get_authority (layer, state);
|
||||||
|
|
||||||
|
color_as_floats[0] = cogl_color_get_red_float (constant_color);
|
||||||
|
color_as_floats[1] = cogl_color_get_green_float (constant_color);
|
||||||
|
color_as_floats[2] = cogl_color_get_blue_float (constant_color);
|
||||||
|
color_as_floats[3] = cogl_color_get_alpha_float (constant_color);
|
||||||
|
|
||||||
if (memcmp (authority->big_state->texture_combine_constant,
|
if (memcmp (authority->big_state->texture_combine_constant,
|
||||||
constant_color, sizeof (float) * 4) == 0)
|
color_as_floats, sizeof (float) * 4) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state);
|
new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state);
|
||||||
@ -5301,7 +5307,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
|
|||||||
CoglPipelineLayerBigState *old_big_state = old_authority->big_state;
|
CoglPipelineLayerBigState *old_big_state = old_authority->big_state;
|
||||||
|
|
||||||
if (memcmp (old_big_state->texture_combine_constant,
|
if (memcmp (old_big_state->texture_combine_constant,
|
||||||
constant_color, sizeof (float) * 4) == 0)
|
color_as_floats, sizeof (float) * 4) == 0)
|
||||||
{
|
{
|
||||||
layer->differences &= ~state;
|
layer->differences &= ~state;
|
||||||
|
|
||||||
@ -5314,14 +5320,9 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layer->big_state->texture_combine_constant[0] =
|
memcpy (layer->big_state->texture_combine_constant,
|
||||||
cogl_color_get_red_float (constant_color);
|
color_as_floats,
|
||||||
layer->big_state->texture_combine_constant[1] =
|
sizeof (color_as_floats));
|
||||||
cogl_color_get_green_float (constant_color);
|
|
||||||
layer->big_state->texture_combine_constant[2] =
|
|
||||||
cogl_color_get_blue_float (constant_color);
|
|
||||||
layer->big_state->texture_combine_constant[3] =
|
|
||||||
cogl_color_get_alpha_float (constant_color);
|
|
||||||
|
|
||||||
/* If we weren't previously the authority on this state then we need
|
/* If we weren't previously the authority on this state then we need
|
||||||
* to extended our differences mask and so it's possible that some
|
* to extended our differences mask and so it's possible that some
|
||||||
|
Loading…
Reference in New Issue
Block a user