[gtk+/wip/otte/rendernode: 32/100] snapshot: Handle clip region as part of the state
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 32/100] snapshot: Handle clip region as part of the state
- Date: Sun, 18 Dec 2016 06:31:23 +0000 (UTC)
commit 110acdef0036d8a7057e94479adbd1e1b481ce03
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 13 01:44:52 2016 +0100
snapshot: Handle clip region as part of the state
This is in preparation for further changes.
gtk/gtksnapshot.c | 16 ++++++++++++----
gtk/gtksnapshotprivate.h | 2 +-
2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 946c308..331e980 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -50,6 +50,7 @@
static GtkSnapshotState *
gtk_snapshot_state_new (GtkSnapshotState *parent,
+ cairo_region_t *clip,
GskRenderNode *node)
{
GtkSnapshotState *state;
@@ -58,6 +59,8 @@ gtk_snapshot_state_new (GtkSnapshotState *parent,
state->node = node;
state->parent = parent;
+ if (clip)
+ state->clip_region = cairo_region_reference (clip);
return state;
}
@@ -65,6 +68,9 @@ gtk_snapshot_state_new (GtkSnapshotState *parent,
static void
gtk_snapshot_state_free (GtkSnapshotState *state)
{
+ if (state->clip_region)
+ cairo_region_destroy (state->clip_region);
+
g_slice_free (GtkSnapshotState, state);
}
@@ -81,7 +87,6 @@ gtk_snapshot_init (GtkSnapshot *snapshot,
snapshot->state = NULL;
snapshot->renderer = renderer;
- snapshot->clip_region = clip;
snapshot->root = gsk_container_node_new ();
if (name)
@@ -98,7 +103,7 @@ gtk_snapshot_init (GtkSnapshot *snapshot,
g_free (str);
}
- snapshot->state = gtk_snapshot_state_new (NULL, snapshot->root);
+ snapshot->state = gtk_snapshot_state_new (NULL, (cairo_region_t *) clip, snapshot->root);
}
GskRenderNode *
@@ -130,7 +135,7 @@ gtk_snapshot_push_node (GtkSnapshot *snapshot,
{
g_return_if_fail (gsk_render_node_get_node_type (node) == GSK_CONTAINER_NODE);
- snapshot->state = gtk_snapshot_state_new (snapshot->state, node);
+ snapshot->state = gtk_snapshot_state_new (snapshot->state, snapshot->state->clip_region, node);
}
/**
@@ -374,10 +379,13 @@ gtk_snapshot_clips_rect (GtkSnapshot *snapshot,
graphene_rect_t offset_bounds;
cairo_rectangle_int_t rect;
+ if (snapshot->state->clip_region == NULL)
+ return FALSE;
+
graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y,
&offset_bounds);
rectangle_init_from_graphene (&rect, &offset_bounds);
- return cairo_region_contains_rectangle (snapshot->clip_region, &rect) == CAIRO_REGION_OVERLAP_OUT;
+ return cairo_region_contains_rectangle (snapshot->state->clip_region, &rect) == CAIRO_REGION_OVERLAP_OUT;
}
/**
diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h
index 74fbf9f..54b3a6b 100644
--- a/gtk/gtksnapshotprivate.h
+++ b/gtk/gtksnapshotprivate.h
@@ -29,6 +29,7 @@ struct _GtkSnapshotState {
GskRenderNode *node;
+ cairo_region_t *clip_region;
double translate_x;
double translate_y;
};
@@ -38,7 +39,6 @@ struct _GtkSnapshot {
GskRenderNode *root;
GskRenderer *renderer;
- const cairo_region_t *clip_region;
};
void gtk_snapshot_init (GtkSnapshot *state,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]