From bf8fb2c1a522fa46fbe1b86e5da16158d7c691fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 31 Jan 2020 08:05:34 +0100 Subject: [PATCH] snapshot: Add _push_collect() and _pop_collect() These will replace the previous gtk_snapshot_new_with_parent(), which allocated an entirely new GObject just to push()/pop() some state. This is already a problem but will be more important in the future as we start using this more. --- gtk/gtksnapshot.c | 24 ++++++++++++++++++++++++ gtk/gtksnapshotprivate.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 5654e0abbc..1804ffb9c2 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -1138,6 +1138,30 @@ gtk_snapshot_pop_internal (GtkSnapshot *snapshot) return gtk_snapshot_pop_one (snapshot); } +/** + * gtk_snapshot_push_collect: + * + * PRIVATE. + * + * Puhses state so a later pop_collect call can collect all nodes + * appended until that point. + */ +void +gtk_snapshot_push_collect (GtkSnapshot *snapshot) +{ + gtk_snapshot_push_state (snapshot, + NULL, + gtk_snapshot_collect_default); +} + +GskRenderNode * +gtk_snapshot_pop_collect (GtkSnapshot *snapshot) +{ + GskRenderNode *result = gtk_snapshot_pop_internal (snapshot); + + return result; +} + /** * gtk_snapshot_to_node: * @snapshot: a #GtkSnapshot diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index e02531e1a5..7317b4ad59 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -104,6 +104,10 @@ void gtk_snapshot_append_text (GtkSnapshot const GdkRGBA *color, float x, float y); + +void gtk_snapshot_push_collect (GtkSnapshot *snapshot); +GskRenderNode * gtk_snapshot_pop_collect (GtkSnapshot *snapshot); + G_END_DECLS #endif /* __GTK_SNAPSHOT_PRIVATE_H__ */