summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-03-19 18:52:12 +0100
committerTimm Bäder <mail@baedert.org>2018-03-20 09:40:10 +0100
commit3f367277fef5d6cdf921428279ba54904b8c9201 (patch)
treef972452cf6986617b40ccaf6789edd9191bc5ff2
parent4240119d64067232eb7fdf0e64062f25e9049ea3 (diff)
downloadgtk+-3f367277fef5d6cdf921428279ba54904b8c9201.tar.gz
snapshot: Limit cairo nodes to clip region
In certain cases, we might create large cairo nodes, resulting in surfaces so large, cairo can't handle them. Fix this by limiting the cairo node to the current clip region.
-rw-r--r--gtk/gtksnapshot.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index c9ebf0b5a0..420f7b6c87 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -1339,6 +1339,20 @@ gtk_snapshot_append_cairo (GtkSnapshot *snapshot,
g_return_val_if_fail (bounds != NULL, NULL);
graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds);
+
+ if (current_state->clip_region)
+ {
+ cairo_rectangle_int_t clip_extents;
+ cairo_region_get_extents (current_state->clip_region, &clip_extents);
+ graphene_rect_intersection (&GRAPHENE_RECT_INIT (
+ clip_extents.x,
+ clip_extents.y,
+ clip_extents.width,
+ clip_extents.height
+ ),
+ &real_bounds, &real_bounds);
+ }
+
node = gsk_cairo_node_new (&real_bounds);
if (name && snapshot->record_names)