[gtk+/wip/baedert/gl: 22/37] snapshot: Only create clip nodes if we have to



commit 574e9e35c3435a3138781d3451add79d803adea0
Author: Timm Bäder <mail baedert org>
Date:   Mon Nov 20 14:14:01 2017 +0100

    snapshot: Only create clip nodes if we have to
    
    gtk_snapshot_push_clip takes a bounds argument that describes the rect
    to be clipped to. If that rect entirely contains the child node bounds,
    we don't need to create a clip node in the first place.

 gtk/gtksnapshot.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 8885806..4ae3f4a 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -548,6 +548,10 @@ gtk_snapshot_collect_clip (GtkSnapshot      *snapshot,
   if (node == NULL)
     return NULL;
 
+  /* Check if the child node will even be clipped */
+  if (graphene_rect_contains_rect (&state->data.clip.bounds, &node->bounds))
+    return node;
+
   clip_node = gsk_clip_node_new (node, &state->data.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]