[gtk+] snapshot: Pass the clip region to the snapshot
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] snapshot: Pass the clip region to the snapshot
- Date: Thu, 17 Nov 2016 02:35:18 +0000 (UTC)
commit 28b32d336f8ce3a36f4930cc3dd991264adc213a
Author: Benjamin Otte <otte redhat com>
Date: Thu Nov 17 02:14:10 2016 +0100
snapshot: Pass the clip region to the snapshot
gtk/gtksnapshot.c | 12 +++++++-----
gtk/gtksnapshotprivate.h | 4 +++-
gtk/gtkwidget.c | 11 +++++++++--
3 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 22752dd..a86df11 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 084331b..c9899d0 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 9ed013a..7e4c56d 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]