[gtk+] snapshot: Always create an initial node
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] snapshot: Always create an initial node
- Date: Fri, 9 Dec 2016 20:41:11 +0000 (UTC)
commit f8932d643d58b515a45ec17a62320197cf087f44
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 9 21:33:38 2016 +0100
snapshot: Always create an initial node
This way we ensure that there is only one root node and everybody can
append() with impunity.
gtk/gtksnapshot.c | 33 +++++++++++++++++++++++++++------
gtk/gtksnapshotprivate.h | 4 +++-
gtk/gtkwidget.c | 5 +++--
3 files changed, 33 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index a037e72..c7c2bd3 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -99,17 +99,42 @@ gtk_snapshot_state_get_world_transform (GtkSnapshotState *state)
void
gtk_snapshot_init (GtkSnapshot *snapshot,
GskRenderer *renderer,
- const cairo_region_t *clip)
+ const cairo_region_t *clip,
+ const char *name,
+ ...)
{
+ cairo_rectangle_int_t extents;
+
+ cairo_region_get_extents (clip, &extents);
+
snapshot->state = NULL;
- snapshot->root = NULL;
snapshot->renderer = renderer;
snapshot->clip_region = clip;
+ snapshot->root = gsk_renderer_create_render_node (renderer);
+ gsk_render_node_set_bounds (snapshot->root, &GRAPHENE_RECT_INIT (extents.x, extents.y, extents.width,
extents.height));
+
+ if (name)
+ {
+ va_list args;
+ char *str;
+
+ va_start (args, name);
+ str = g_strdup_vprintf (name, args);
+ va_end (args);
+
+ gsk_render_node_set_name (snapshot->root, str);
+
+ g_free (str);
+ }
+
+ snapshot->state = gtk_snapshot_state_new (NULL, snapshot->root);
}
GskRenderNode *
gtk_snapshot_finish (GtkSnapshot *snapshot)
{
+ gtk_snapshot_pop (snapshot);
+
if (snapshot->state != NULL)
{
g_warning ("Too many gtk_snapshot_push() calls.");
@@ -305,10 +330,6 @@ gtk_snapshot_append_node (GtkSnapshot *snapshot,
gsk_render_node_append_child (snapshot->state->node, node);
gsk_render_node_set_transform (node, &snapshot->state->transform);
}
- else if (snapshot->root == NULL)
- {
- snapshot->root = gsk_render_node_ref (node);
- }
else
{
g_critical ("Tried appending a node to an already finished snapshot.");
diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h
index ff9d1b6..2f70962 100644
--- a/gtk/gtksnapshotprivate.h
+++ b/gtk/gtksnapshotprivate.h
@@ -44,7 +44,9 @@ struct _GtkSnapshot {
void gtk_snapshot_init (GtkSnapshot *state,
GskRenderer *renderer,
- const cairo_region_t *clip);
+ const cairo_region_t *clip,
+ const char *name,
+ ...) G_GNUC_PRINTF (4, 5);
GskRenderNode * gtk_snapshot_finish (GtkSnapshot *state);
static inline const graphene_matrix_t *
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 168bdf6..162d67a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6338,7 +6338,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
widget->priv->clip.width,
widget->priv->clip.height});
fallback = gsk_renderer_create_fallback (renderer, &viewport, cr);
- gtk_snapshot_init (&snapshot, renderer, clip);
+ gtk_snapshot_init (&snapshot, renderer, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
gtk_widget_snapshot (widget, &snapshot);
node = gtk_snapshot_finish (&snapshot);
if (node != NULL)
@@ -15623,7 +15623,8 @@ gtk_widget_render (GtkWidget *widget,
gtk_snapshot_init (&snapshot,
renderer,
- gdk_drawing_context_get_clip (context));
+ gdk_drawing_context_get_clip (context),
+ "Render<%s>", G_OBJECT_TYPE_NAME (widget));
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]