mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
material-node: track if node owns reference on parent
MaterialNodes are used for the sparse graph of material state and layer state. In the case of materials there is the idea of weak materials that don't take a reference on their parent and in that case we need to be careful not to unref our parent during _cogl_material_node_unparent_real. This adds a has_parent_reference member to the CoglMaterialNode struct so we now know when to skip the unref.
This commit is contained in:
parent
e5202d6a0d
commit
bbf27e6b28
@ -138,6 +138,10 @@ struct _CoglMaterialNode
|
|||||||
/* The parent material/layer */
|
/* The parent material/layer */
|
||||||
CoglMaterialNode *parent;
|
CoglMaterialNode *parent;
|
||||||
|
|
||||||
|
/* TRUE if the node took a strong reference on its parent. Weak
|
||||||
|
* materials for instance don't take a reference on their parent. */
|
||||||
|
gboolean has_parent_reference;
|
||||||
|
|
||||||
/* As an optimization for creating leaf node materials/layers (the
|
/* As an optimization for creating leaf node materials/layers (the
|
||||||
* most common) we don't require any list node allocations to link
|
* most common) we don't require any list node allocations to link
|
||||||
* to a single descendant. */
|
* to a single descendant. */
|
||||||
|
@ -127,6 +127,7 @@ _cogl_material_node_set_parent_real (CoglMaterialNode *node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
node->parent = parent;
|
node->parent = parent;
|
||||||
|
node->has_parent_reference = take_strong_reference;
|
||||||
|
|
||||||
/* Now that there is a consistent parent->child link we can remove
|
/* Now that there is a consistent parent->child link we can remove
|
||||||
* the parent reference if no reference was requested. If it turns
|
* the parent reference if no reference was requested. If it turns
|
||||||
@ -160,7 +161,8 @@ _cogl_material_node_unparent_real (CoglMaterialNode *node)
|
|||||||
else
|
else
|
||||||
parent->children = g_list_remove (parent->children, node);
|
parent->children = g_list_remove (parent->children, node);
|
||||||
|
|
||||||
cogl_object_unref (parent);
|
if (node->has_parent_reference)
|
||||||
|
cogl_object_unref (parent);
|
||||||
|
|
||||||
node->parent = NULL;
|
node->parent = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user