[gtk+] gsk: Add gsk_render_node_write_to_file()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gsk: Add gsk_render_node_write_to_file()
- Date: Fri, 23 Dec 2016 07:45:32 +0000 (UTC)
commit 5e089c43453e34432f6c9e47b2d064129f391a56
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 23 05:58:07 2016 +0100
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...
docs/reference/gsk/gsk4-sections.txt | 3 ++
gsk/gskrendernode.c | 36 ++++++++++++++++++++++++++++++++++
gsk/gskrendernode.h | 4 +++
3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index eebc74d..1a2c526 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -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
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index d6a14b3..8ce7da7 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -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)
{
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 650ac9b..f36cafc 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]