[gtk] gl renderer: Add debug function to dump render node



commit f0624266dc49c502dc664c8c65e642314664afb3
Author: Timm Bäder <mail baedert org>
Date:   Sun Feb 24 09:09:02 2019 +0100

    gl renderer: Add debug function to dump render node

 gsk/gl/gskglrenderer.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 4128953430..4033e42052 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -141,6 +141,30 @@ dump_framebuffer (const char *filename, int w, int h)
   g_free (data);
 }
 
+static void G_GNUC_UNUSED
+dump_node (GskRenderNode *node,
+           const char    *filename)
+{
+  const int surface_width = ceilf (node->bounds.size.width);
+  const int surface_height = ceilf (node->bounds.size.height);
+  cairo_surface_t *surface;
+  cairo_t *cr;
+
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                        surface_width,
+                                        surface_height);
+
+  cr = cairo_create (surface);
+  cairo_save (cr);
+  cairo_translate (cr, -node->bounds.origin.x, -node->bounds.origin.y);
+  gsk_render_node_draw (node, cr);
+  cairo_restore (cr);
+  cairo_destroy (cr);
+
+  cairo_surface_write_to_png (surface, filename);
+  cairo_surface_destroy (surface);
+}
+
 static gboolean
 font_has_color_glyphs (const PangoFont *font)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]