snapshot: Pass the clip region to the snapshot

This commit is contained in:
Benjamin Otte 2016-11-17 02:14:10 +01:00
parent 7493f90662
commit 28b32d336f
3 changed files with 19 additions and 8 deletions

View File

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

View File

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

View File

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