Struct
GskRenderReplay
unstable since: 4.22
Description [src]
struct GskRenderReplay {
/* No available fields */
}
A facility to replay a GskRenderNode and its children, potentially
modifying them.
This is a utility tool to walk a rendernode tree. The most powerful way
is to provide a function via gsk_render_replay_set_node_filter()
to filter each individual node and then run
gsk_render_replay_filter_node() on the nodes you want to filter.
An easier method exists to just walk the node tree and extract information
without any modifications. If you want to do that, the functions
gsk_render_replay_set_node_foreach() exists. You can also call
gsk_render_replay_foreach_node() to run that function. Note that
the previously mentioned complex functionality will still be invoked if you
have set up a function for it, but its result will not be returned.
Here is an example that combines both approaches to print the whole tree:
#include <gtk/gtk.h>
static GskRenderNode *
print_nodes (GskRenderReplay *replay,
GskRenderNode *node,
gpointer user_data)
{
int *depth = user_data;
GskRenderNode *result;
g_print ("%*s%s\n", 2 * *depth, "", g_type_name_from_instance ((GTypeInstance *) node));
*depth += 1;
result = gsk_render_replay_default (replay, node);
*depth -= 1;
return result;
}
int
main (int argc, char *argv[])
{
GFile *file;
GBytes *bytes;
GskRenderNode *node;
GskRenderReplay *replay;
int depth = 0;
gtk_init ();
if (argc < 2)
{
g_print ("usage: %s NODEFILE\n", argv[0]);
return 0;
}
file = g_file_new_for_commandline_arg (argv[1]);
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
g_object_unref (file);
if (bytes == NULL)
return 1;
node = gsk_render_node_deserialize (bytes, NULL, NULL);
g_bytes_unref (bytes);
if (node == NULL)
return 1;
replay = gsk_render_replay_new ();
gsk_render_replay_set_node_filter (replay, print_nodes, &depth, NULL);
gsk_render_node_foreach_node (replay, node);
gsk_render_node_unref (node);
return 0;
}
Available since: 4.22
Instance methods
gsk_render_replay_filter_font
Filters a font using the current filter function.
unstable since: 4.22
gsk_render_replay_filter_node
Replays a node using the replay’s filter function.
unstable since: 4.22
gsk_render_replay_filter_texture
Filters a texture using the current filter function.
unstable since: 4.22
gsk_render_replay_foreach_node
Calls the filter and foreach functions for each node.
unstable since: 4.22
gsk_render_replay_set_font_filter
Sets a filter function to be called by gsk_render_replay_default()
for nodes that contain fonts.
unstable since: 4.22
gsk_render_replay_set_texture_filter
Sets a filter function to be called by gsk_render_replay_default()
for nodes that contain textures.
unstable since: 4.22