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.
This commit is contained in:
Timm Bäder 2017-12-01 07:38:43 +01:00
parent 7b60ee9316
commit 94184eda42

View File

@ -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)