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.
This commit is contained in:
Timm Bäder 2020-01-31 08:05:34 +01:00 committed by Matthias Clasen
parent b7ee2cbc28
commit bf8fb2c1a5
2 changed files with 28 additions and 0 deletions

View File

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

View File

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