summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-11-17 02:14:10 +0100
committerBenjamin Otte <otte@redhat.com>2016-11-17 02:14:10 +0100
commit28b32d336f8ce3a36f4930cc3dd991264adc213a (patch)
tree7056ff2d3ab1d1c1aec983d00637c303a485a425
parent7493f906626e4800e7e05186d95291e48aaa89a7 (diff)
downloadgtk+-28b32d336f8ce3a36f4930cc3dd991264adc213a.tar.gz
snapshot: Pass the clip region to the snapshot
-rw-r--r--gtk/gtksnapshot.c12
-rw-r--r--gtk/gtksnapshotprivate.h4
-rw-r--r--gtk/gtkwidget.c11
3 files changed, 19 insertions, 8 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 22752ddaf7..a86df11d89 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -58,12 +58,14 @@ gtk_snapshot_state_set_transform (GtkSnapshotState *state,
}
void
-gtk_snapshot_init (GtkSnapshot *state,
- GskRenderer *renderer)
+gtk_snapshot_init (GtkSnapshot *snapshot,
+ GskRenderer *renderer,
+ const cairo_region_t *clip)
{
- state->state = NULL;
- state->root = NULL;
- state->renderer = renderer;
+ snapshot->state = NULL;
+ snapshot->root = NULL;
+ snapshot->renderer = renderer;
+ snapshot->clip_region = clip;
}
GskRenderNode *
diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h
index 084331b525..c9899d004f 100644
--- a/gtk/gtksnapshotprivate.h
+++ b/gtk/gtksnapshotprivate.h
@@ -37,10 +37,12 @@ struct _GtkSnapshot {
GskRenderNode *root;
GskRenderer *renderer;
+ const cairo_region_t *clip_region;
};
void gtk_snapshot_init (GtkSnapshot *state,
- GskRenderer *renderer);
+ GskRenderer *renderer,
+ const cairo_region_t *clip);
GskRenderNode * gtk_snapshot_finish (GtkSnapshot *state);
static inline const graphene_matrix_t *
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9ed013a66c..7e4c56d56e 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6409,6 +6409,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
GtkSnapshot snapshot;
GskRenderer *fallback;
graphene_rect_t viewport;
+ cairo_region_t *clip;
GskRenderNode *node;
graphene_rect_init (&viewport,
@@ -6416,8 +6417,13 @@ gtk_widget_draw_internal (GtkWidget *widget,
widget->priv->allocation.y - widget->priv->clip.y,
widget->priv->clip.width,
widget->priv->clip.height);
+ clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
+ widget->priv->allocation.x - widget->priv->clip.x,
+ widget->priv->allocation.y - widget->priv->clip.y,
+ widget->priv->clip.width,
+ widget->priv->clip.height});
fallback = gsk_renderer_create_fallback (renderer, &viewport, cr);
- gtk_snapshot_init (&snapshot, renderer);
+ gtk_snapshot_init (&snapshot, renderer, clip);
gtk_widget_snapshot (widget, &snapshot);
node = gtk_snapshot_finish (&snapshot);
if (node != NULL)
@@ -6426,6 +6432,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
gsk_render_node_unref (node);
}
+ cairo_region_destroy (clip);
g_object_unref (fallback);
}
else
@@ -15713,7 +15720,7 @@ gtk_widget_render (GtkWidget *widget,
if (renderer == NULL)
return;
- gtk_snapshot_init (&snapshot, renderer);
+ gtk_snapshot_init (&snapshot, renderer, region);
gtk_widget_snapshot (widget, &snapshot);
root = gtk_snapshot_finish (&snapshot);
if (root == NULL)