From 94184eda4214b3162eead554212443b3a0f50481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 1 Dec 2017 07:38:43 +0100 Subject: [PATCH] snapshot: Only create clip nodes if we need to Clip nodes have a clip rect and we only need to actually create a clip node if any child node gets clipped at all. If the clip rect conains the child node bounds entirely, we don't need a clip node. --- gtk/gtksnapshot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 4995c3dc8c..c969fdece6 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; + /* 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)