mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
material: fix initialization of sparse properties
In _cogl_material_pre_change_notify we need to identify if it's a sparse property being changed and if so initialize the state group if the given material isn't currently the authority for it. Previously we were unconditionally calling _cogl_material_initialize_state which would e.g. NULL the layer differences list of a material each time a layer change was notified. It would also call _cogl_material_initialize_state for non-sparse properties which should always be valid at this point so the function has been renamed to _cogl_material_initialize_sparse_state to make this clearer with a corresponding g_return_if_fail check.
This commit is contained in:
parent
02ce77dc08
commit
021265e634
@ -916,13 +916,15 @@ check_for_blending_change:
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_material_initialize_state (CoglMaterial *dest,
|
||||
CoglMaterial *src,
|
||||
CoglMaterialState state)
|
||||
_cogl_material_initialize_sparse_state (CoglMaterial *dest,
|
||||
CoglMaterial *src,
|
||||
CoglMaterialState state)
|
||||
{
|
||||
if (dest == src)
|
||||
return;
|
||||
|
||||
g_return_if_fail (state & COGL_MATERIAL_STATE_ALL_SPARSE);
|
||||
|
||||
if (state != COGL_MATERIAL_STATE_LAYERS)
|
||||
_cogl_material_copy_differences (dest, src, state);
|
||||
else
|
||||
@ -1087,14 +1089,15 @@ _cogl_material_pre_change_notify (CoglMaterial *material,
|
||||
|
||||
material->age++;
|
||||
|
||||
/* If the material isn't already an authority for the state group
|
||||
* being modified then we need to initialize the corresponding
|
||||
* state. */
|
||||
if (change & COGL_MATERIAL_STATE_ALL_SPARSE)
|
||||
authority = _cogl_material_get_authority (material, change);
|
||||
else
|
||||
authority = material;
|
||||
_cogl_material_initialize_state (material, authority, change);
|
||||
/* If changing a sparse property and if the material isn't already an
|
||||
* authority for the state group being modified then we need to
|
||||
* initialize the corresponding state. */
|
||||
if (change & COGL_MATERIAL_STATE_ALL_SPARSE &&
|
||||
!(material->differences & change))
|
||||
{
|
||||
authority = _cogl_material_get_authority (material, change);
|
||||
_cogl_material_initialize_sparse_state (material, authority, change);
|
||||
}
|
||||
|
||||
/* Each material has a sorted cache of the layers it depends on
|
||||
* which will need updating via _cogl_material_update_layers_cache
|
||||
|
Loading…
Reference in New Issue
Block a user