[gtk+] snapashot: Optimize rounded clip nodes



commit c42e0260589e9664d7d71c000002814fe71fcd4f
Author: Timm Bäder <mail baedert org>
Date:   Fri Dec 1 08:04:31 2017 +0100

    snapashot: Optimize rounded clip nodes
    
    If the rounded clip node is rectilinear, we can simplify it to a normal
    clip node. If not, we really need to use a rounded clip node. In both
    cases, we can do the same check we do when collecting normal clips and
    avoid the clip node altogether if the child node does not get clipped
    anyway.
    
    This saves between 3 and 10 nodes in the widget factory, depending on
    what page gets rendered.

 gtk/gtksnapshot.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index c969fde..a5d4c39 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -636,7 +636,23 @@ gtk_snapshot_collect_rounded_clip (GtkSnapshot      *snapshot,
   if (node == NULL)
     return NULL;
 
-  clip_node = gsk_rounded_clip_node_new (node, &state->data.rounded_clip.bounds);
+  /* If the given radius is 0 in all corners, we can just create a normal clip node */
+  if (gsk_rounded_rect_is_rectilinear (&state->data.rounded_clip.bounds))
+    {
+      /* ... and do the same optimization */
+      if (graphene_rect_contains_rect (&state->data.rounded_clip.bounds.bounds, &node->bounds))
+        return node;
+
+      clip_node = gsk_clip_node_new (node, &state->data.rounded_clip.bounds.bounds);
+    }
+  else
+    {
+      if (gsk_rounded_rect_contains_rect (&state->data.rounded_clip.bounds, &node->bounds))
+        return node;
+
+      clip_node = gsk_rounded_clip_node_new (node, &state->data.rounded_clip.bounds);
+    }
+
   if (name)
     gsk_render_node_set_name (clip_node, name);
 


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