diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index d846d7b0fb..1fc517ece1 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -125,13 +125,13 @@ gtk_snapshot_state_clear (GtkSnapshotState *state) g_clear_pointer (&state->name, g_free); } -void -gtk_snapshot_init (GtkSnapshot *snapshot, - GskRenderer *renderer, - gboolean record_names, - const cairo_region_t *clip, - const char *name, - ...) +static void +gtk_snapshot_init_va (GtkSnapshot *snapshot, + GskRenderer *renderer, + gboolean record_names, + const cairo_region_t *clip, + const char *name, + va_list args) { char *str; @@ -142,13 +142,7 @@ gtk_snapshot_init (GtkSnapshot *snapshot, snapshot->nodes = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_render_node_unref); if (name && record_names) - { - va_list args; - - va_start (args, name); - str = g_strdup_vprintf (name, args); - va_end (args); - } + str = g_strdup_vprintf (name, args); else str = NULL; @@ -159,6 +153,38 @@ gtk_snapshot_init (GtkSnapshot *snapshot, gtk_snapshot_collect_default); } +void +gtk_snapshot_init (GtkSnapshot *snapshot, + GskRenderer *renderer, + gboolean record_names, + const cairo_region_t *clip, + const char *name, + ...) +{ + va_list args; + + va_start (args, name); + gtk_snapshot_init_va (snapshot, renderer, record_names, clip, name, args); + va_end (args); +} + +GtkSnapshot * +gtk_snapshot_new (GtkSnapshot *parent, + const char *name, + ...) +{ + GtkSnapshot *snapshot; + va_list args; + + snapshot = g_new (GtkSnapshot, 1); + + va_start (args, name); + gtk_snapshot_init_va (snapshot, parent->renderer, parent->record_names, NULL, name, args); + va_end (args); + + return snapshot; +} + /** * gtk_snapshot_push: * @snapshot: a #GtkSnapshot @@ -1021,6 +1047,17 @@ gtk_snapshot_finish (GtkSnapshot *snapshot) return result; } +GskRenderNode * +gtk_snapshot_free (GtkSnapshot *snapshot) +{ + GskRenderNode *node; + + node = gtk_snapshot_finish (snapshot); + g_free (snapshot); + + return node; +} + /** * gtk_snapshot_pop: * @snapshot: a #GtkSnapshot diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h index b5e21ae6ed..c10b84c5a2 100644 --- a/gtk/gtksnapshot.h +++ b/gtk/gtksnapshot.h @@ -36,6 +36,13 @@ G_BEGIN_DECLS +GDK_AVAILABLE_IN_3_92 +GtkSnapshot * gtk_snapshot_new (GtkSnapshot *parent, + const char *name, + ...) G_GNUC_PRINTF (2, 3); +GDK_AVAILABLE_IN_3_92 +GskRenderNode * gtk_snapshot_free (GtkSnapshot *snapshot); + GDK_AVAILABLE_IN_3_90 void gtk_snapshot_push (GtkSnapshot *snapshot, gboolean keep_coordinates, diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 1319df7d7b..0682a8d0ff 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -87,14 +87,17 @@ struct _GtkSnapshot { GPtrArray *nodes; }; +GDK_AVAILABLE_IN_ALL void gtk_snapshot_init (GtkSnapshot *state, GskRenderer *renderer, gboolean record_names, const cairo_region_t *clip, const char *name, ...) G_GNUC_PRINTF (5, 6); +GDK_AVAILABLE_IN_ALL GskRenderNode * gtk_snapshot_finish (GtkSnapshot *state); +GDK_AVAILABLE_IN_ALL GskRenderer * gtk_snapshot_get_renderer (const GtkSnapshot *snapshot); G_END_DECLS diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index ff2aa771ba..65bcb31c7c 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -518,6 +518,10 @@ void gtk_widget_unrealize (GtkWidget *widget); GDK_AVAILABLE_IN_ALL void gtk_widget_draw (GtkWidget *widget, cairo_t *cr); +GDK_AVAILABLE_IN_3_92 +void gtk_widget_snapshot (GtkWidget *widget, + GtkSnapshot *snapshot); + /* Queuing draws */ GDK_AVAILABLE_IN_ALL void gtk_widget_queue_draw (GtkWidget *widget); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 6e0b746a2c..0b7595e1ce 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -282,9 +282,6 @@ void gtk_widget_render (GtkWidget GdkWindow *window, const cairo_region_t *region); - -void gtk_widget_snapshot (GtkWidget *widget, - GtkSnapshot *snapshot); void gtk_widget_adjust_size_request (GtkWidget *widget, GtkOrientation orientation, gint *minimum_size,