[gtk+/wip/alexl/broadway4: 36/39] gtksnapshot: Merge trivial clip duplicates



commit d95cbb275729370a2dd67e24570ac1c68b62b697
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Nov 30 15:31:46 2017 +0100

    gtksnapshot: Merge trivial clip duplicates
    
    I got a lot of "clip in clip" cases, for example a CellClip with a
    CellTextClip inside. It is really trivial to merge these when we
    pop and makes it easier for all backends, so lets do that.

 gtk/gtksnapshot.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index e97efb9..4995c3d 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -548,7 +548,21 @@ gtk_snapshot_collect_clip (GtkSnapshot      *snapshot,
   if (node == NULL)
     return NULL;
 
-  clip_node = gsk_clip_node_new (node, &state->data.clip.bounds);
+  /* Its not uncommon to produce stacked clip nodes, which are trivial
+     to merge, so do that here */
+  if (gsk_render_node_get_node_type (node) == GSK_CLIP_NODE)
+    {
+      GskRenderNode *child = gsk_clip_node_get_child (node);
+      const graphene_rect_t *node_clip = gsk_clip_node_peek_clip (node);
+      graphene_rect_t merged_clip;
+
+      graphene_rect_intersection (&state->data.clip.bounds, node_clip, &merged_clip);
+      clip_node = gsk_clip_node_new (child, &state->data.clip.bounds);
+      gsk_render_node_unref (node);
+    }
+  else
+    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]