### Struct

# Gsk RenderReplay

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.

If you want to just walk the node tree and extract information without any modifications, you can also use `gsk_render_node_get_children()`.

Here is a little example application that redacts text in a node file:

    #include <gtk/gtk.h>

    static GskRenderNode *
    redact_nodes (GskRenderReplay *replay,
                  GskRenderNode   *node,
                  gpointer         user_data)
    {
      GskRenderNode *result;

      if (gsk_render_node_get_node_type (node) == GSK_TEXT_NODE)
        {
          graphene_rect_t bounds;
          const GdkRGBA *color;

          gsk_render_node_get_bounds (node, &bounds);
          color = gsk_text_node_get_color (node);

          result = gsk_color_node_new (color, &bounds);
        }
      else
        {
          result = gsk_render_replay_default (replay, node);
        }

      return result;
    }

    int
    main (int argc, char *argv[])
    {
      GFile *file;
      GBytes *bytes;
      GskRenderNode *result, *node;
      GskRenderReplay *replay;

      gtk_init ();

      if (argc != 3)
        {
          g_print ("usage: %s INFILE OUTFILE\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, redact_nodes, NULL, NULL);
      result = gsk_render_replay_filter_node (replay, node);
      gsk_render_replay_free (replay);

      if (!gsk_render_node_write_to_file (result, argv[2], NULL))
        return 1;

      gsk_render_node_unref (result);
      gsk_render_node_unref (node);

      return 0;
    }

Available since: 4.22

#### Constructors

###### gsk_render_replay_new

Creates a new replay object to replay nodes.

since: 4.22

#### Instance methods

###### gsk_render_replay_default

Replays the node using the default method.

since: 4.22

###### gsk_render_replay_filter_font

Filters a font using the current filter function.

since: 4.22

###### gsk_render_replay_filter_node

Replays a node using the replay’s filter function.

since: 4.22

###### gsk_render_replay_filter_texture

Filters a texture using the current filter function.

since: 4.22

###### gsk_render_replay_free

Frees a `GskRenderReplay`.

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.

since: 4.22

###### gsk_render_replay_set_node_filter

Sets the function to use as a node filter.

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.

since: 4.22