gsk: remove excessive type checking within GSK

Anything that includes gskrendernodeprivate.h will get an alternate form
of ref/unref for render nodes which does not need to do type checking on
the parameter. We can expect that things are correct within GTK itself and
this saves excessive amounts of TypeNode conformities checking.
This commit is contained in:
Christian Hergert 2023-09-26 18:28:11 -07:00
parent 83376648d7
commit eb646a8e8b
2 changed files with 23 additions and 7 deletions

View File

@ -287,15 +287,21 @@ gsk_render_node_alloc (GskRenderNodeType node_type)
* Returns: (transfer full): the `GskRenderNode` with an additional reference
*/
GskRenderNode *
gsk_render_node_ref (GskRenderNode *node)
(gsk_render_node_ref) (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
g_atomic_ref_count_inc (&node->ref_count);
return node;
return _gsk_render_node_ref (node);
}
void
_gsk_render_node_unref (GskRenderNode *node)
{
if G_UNLIKELY (g_atomic_ref_count_dec (&node->ref_count))
GSK_RENDER_NODE_GET_CLASS (node)->finalize (node);
}
/**
* gsk_render_node_unref:
* @node: (transfer full): a `GskRenderNode`
@ -306,12 +312,11 @@ gsk_render_node_ref (GskRenderNode *node)
* freed.
*/
void
gsk_render_node_unref (GskRenderNode *node)
(gsk_render_node_unref) (GskRenderNode *node)
{
g_return_if_fail (GSK_IS_RENDER_NODE (node));
if (g_atomic_ref_count_dec (&node->ref_count))
GSK_RENDER_NODE_GET_CLASS (node)->finalize (node);
_gsk_render_node_unref (node);
}

View File

@ -57,6 +57,8 @@ GType gsk_render_node_type_register_static (const char
gpointer gsk_render_node_alloc (GskRenderNodeType node_type);
void _gsk_render_node_unref (GskRenderNode *node);
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2) G_GNUC_PURE;
void gsk_render_node_diff (GskRenderNode *node1,
@ -87,6 +89,15 @@ gboolean gsk_container_node_is_disjoint (const GskRenderNode
gboolean gsk_render_node_use_offscreen_for_opacity (const GskRenderNode *node);
#define gsk_render_node_ref(node) _gsk_render_node_ref(node)
#define gsk_render_node_unref(node) _gsk_render_node_unref(node)
static inline GskRenderNode *
_gsk_render_node_ref (GskRenderNode *node)
{
g_atomic_ref_count_inc (&node->ref_count);
return node;
}
G_END_DECLS