[gtk/misc-speedups: 3/11] gsk: Add a private getter for container children




commit 7fb13896485ccea9520cd2948c2caacbe5ba426b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 24 09:49:09 2021 -0400

    gsk: Add a private getter for container children
    
    No need to get them one-by-one, in our inner loop.

 gsk/gskrendernodeimpl.c    | 11 +++++++++++
 gsk/gskrendernodeprivate.h |  4 ++++
 gsk/ngl/gsknglrenderjob.c  |  9 ++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index c7751b8e3a..ef008f8294 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -2780,6 +2780,17 @@ gsk_container_node_get_child (const GskRenderNode *node,
   return self->children[idx];
 }
 
+GskRenderNode **
+gsk_container_node_get_children (const GskRenderNode *node,
+                                 guint               *n_children)
+{
+  const GskContainerNode *self = (const GskContainerNode *) node;
+
+  *n_children = self->n_children;
+
+  return self->children;
+}
+
 /*** GSK_TRANSFORM_NODE ***/
 
 /**
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 8fef8e7aa4..b9e719cdfb 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -103,6 +103,10 @@ bool            gsk_border_node_get_uniform_color       (const GskRenderNode
 void            gsk_text_node_serialize_glyphs          (GskRenderNode               *self,
                                                          GString                     *str);
 
+GskRenderNode ** gsk_container_node_get_children        (const GskRenderNode *node,
+                                                         guint               *n_children);
+
+
 G_END_DECLS
 
 #endif /* __GSK_RENDER_NODE_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 40e730557f..6f87340624 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -3536,18 +3536,21 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob     *job,
 
     case GSK_CONTAINER_NODE:
       {
-        guint n_children = gsk_container_node_get_n_children (node);
+        GskRenderNode **children;
+        guint n_children;
+
+        children = gsk_container_node_get_children (node, &n_children);
 
         for (guint i = 0; i < n_children; i++)
           {
-            const GskRenderNode *child = gsk_container_node_get_child (node, i);
+            const GskRenderNode *child = children[i];
 
             if (i + 1 < n_children &&
                 job->current_clip->is_fully_contained &&
                 gsk_render_node_get_node_type (child) == GSK_ROUNDED_CLIP_NODE)
               {
                 const GskRenderNode *grandchild = gsk_rounded_clip_node_get_child (child);
-                const GskRenderNode *child2 = gsk_container_node_get_child (node, i + 1);
+                const GskRenderNode *child2 = children[i + 1];
                 if (gsk_render_node_get_node_type (grandchild) == GSK_COLOR_NODE &&
                     gsk_render_node_get_node_type (child2) == GSK_BORDER_NODE &&
                     gsk_border_node_get_uniform_color (child2) &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]