gsk: Add gsk_render_node_write_to_file()

For when you're in a debugger and need to have a closer look at this
node...
This commit is contained in:
Benjamin Otte 2016-12-23 05:58:07 +01:00
parent 087ea8e531
commit 5e089c4345
3 changed files with 43 additions and 0 deletions

View File

@ -30,6 +30,9 @@ gsk_render_node_unref
GskRenderNodeType
gsk_render_node_get_node_type
gsk_render_node_draw
gsk_render_node_serialize
gsk_render_node_deserialize
gsk_render_node_write_to_file
GskScalingFilter
gsk_render_node_set_scaling_filters
gsk_render_node_set_name

View File

@ -317,6 +317,42 @@ gsk_render_node_serialize (GskRenderNode *node)
return result;
}
/**
* gsk_render_node_write_to_file:
* @node: a #GskRenderNode
* @filename: the file to save it to.
* @error: Return location for a potential error
*
* This function is equivalent to calling gsk_render_node_serialize()
* followed by g_file_set_contents(). See those two functions for details
* on the arguments.
*
* It is mostly intended for use inside a debugger to quickly dump a render
* node to a file for later inspection.
*
* Returns: %TRUE if saving was successful
**/
gboolean
gsk_render_node_write_to_file (GskRenderNode *node,
const char *filename,
GError **error)
{
GBytes *bytes;
gboolean result;
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
bytes = gsk_render_node_serialize (node);
result = g_file_set_contents (filename,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes),
error);
return result;
}
GskRenderNode *
gsk_render_node_deserialize (GBytes *bytes)
{

View File

@ -177,6 +177,10 @@ void gsk_render_node_draw (GskRenderNode *
GDK_AVAILABLE_IN_3_90
GBytes * gsk_render_node_serialize (GskRenderNode *node);
GDK_AVAILABLE_IN_3_90
gboolean gsk_render_node_write_to_file (GskRenderNode *node,
const char *filename,
GError **error);
GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_render_node_deserialize (GBytes *bytes);
G_END_DECLS