summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-04-03 19:28:53 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-04-05 14:57:38 -0400
commit0eba21b2b58593599829732c5556f0a15ed75a06 (patch)
tree6df7e194b77be50c0f2862578b1f56953354eae8
parentaf20f7e9b5e1c1f035148b72382019b08122e97d (diff)
downloadgtk+-0eba21b2b58593599829732c5556f0a15ed75a06.tar.gz
gsk: Track disjointness of container nodes
This can be used to optimize some things in the GL renderer.
-rw-r--r--gsk/gskrendernodeimpl.c21
-rw-r--r--gsk/gskrendernodeprivate.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 384de83bad..53b7d35f9d 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -2576,6 +2576,7 @@ struct _GskContainerNode
{
GskRenderNode render_node;
+ gboolean disjoint;
guint n_children;
GskRenderNode **children;
};
@@ -2724,6 +2725,7 @@ gsk_container_node_new (GskRenderNode **children,
self = gsk_render_node_alloc (GSK_CONTAINER_NODE);
node = (GskRenderNode *) self;
+ self->disjoint = TRUE;
self->n_children = n_children;
if (n_children == 0)
@@ -2743,6 +2745,7 @@ gsk_container_node_new (GskRenderNode **children,
for (guint i = 1; i < n_children; i++)
{
self->children[i] = gsk_render_node_ref (children[i]);
+ self->disjoint &= !graphene_rect_intersection (&bounds, &(children[i]->bounds), NULL);
graphene_rect_union (&bounds, &(children[i]->bounds), &bounds);
node->prefers_high_depth |= gsk_render_node_prefers_high_depth (children[i]);
}
@@ -2801,6 +2804,24 @@ gsk_container_node_get_children (const GskRenderNode *node,
return self->children;
}
+/*< private>
+ * gsk_container_node_is_disjoint:
+ * @node: a container `GskRenderNode`
+ *
+ * Returns `TRUE` if it is known that the child nodes are not
+ * overlapping. There is no guarantee that they do overlap
+ * if this function return FALSE.
+ *
+ * Returns: `TRUE` if children don't overlap
+ */
+gboolean
+gsk_container_node_is_disjoint (const GskRenderNode *node)
+{
+ const GskContainerNode *self = (const GskContainerNode *) node;
+
+ return self->disjoint;
+}
+
/*** GSK_TRANSFORM_NODE ***/
/**
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index cdb75afd2f..637e6cb4fd 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -113,6 +113,8 @@ void gsk_transform_node_get_translate (const GskRenderNode *no
float *dy);
gboolean gsk_render_node_prefers_high_depth (const GskRenderNode *node);
+gboolean gsk_container_node_is_disjoint (const GskRenderNode *node);
+
G_END_DECLS