[gtk+/wip/matthiasc/glyph-cache] Add some debug output for the glyph cache



commit a50c1b1d88368012a1b0a25f4debdd2779e574c8
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 19 23:59:44 2017 -0400

    Add some debug output for the glyph cache
    
    Print out some statistics and dump the glyph caches to a png,
    for now.

 gsk/gskdebug.c            |    3 ++-
 gsk/gskdebugprivate.h     |    3 ++-
 gsk/gskvulkanglyphcache.c |   22 ++++++++++++++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskdebug.c b/gsk/gskdebug.c
index 94d40b7..41d6668 100644
--- a/gsk/gskdebug.c
+++ b/gsk/gskdebug.c
@@ -10,7 +10,8 @@ static const GDebugKey gsk_debug_keys[] = {
   { "transforms", GSK_DEBUG_TRANSFORMS },
   { "surface", GSK_DEBUG_SURFACE },
   { "vulkan", GSK_DEBUG_VULKAN },
-  { "fallback", GSK_DEBUG_FALLBACK }
+  { "fallback", GSK_DEBUG_FALLBACK },
+  { "glyphcache", GSK_DEBUG_GLYPH_CACHE }
 };
 #endif
 
diff --git a/gsk/gskdebugprivate.h b/gsk/gskdebugprivate.h
index 0f82c80..c84bfe4 100644
--- a/gsk/gskdebugprivate.h
+++ b/gsk/gskdebugprivate.h
@@ -14,7 +14,8 @@ typedef enum {
   GSK_DEBUG_TRANSFORMS  = 1 << 5,
   GSK_DEBUG_SURFACE     = 1 << 6,
   GSK_DEBUG_VULKAN      = 1 << 7,
-  GSK_DEBUG_FALLBACK    = 1 << 8
+  GSK_DEBUG_FALLBACK    = 1 << 8,
+  GSK_DEBUG_GLYPH_CACHE = 1 << 9
 } GskDebugFlags;
 
 #define GSK_DEBUG_ANY ((1 << 9) - 1)
diff --git a/gsk/gskvulkanglyphcache.c b/gsk/gskvulkanglyphcache.c
index fc36b0a..69181f6 100644
--- a/gsk/gskvulkanglyphcache.c
+++ b/gsk/gskvulkanglyphcache.c
@@ -13,6 +13,7 @@ typedef struct {
   GskVulkanImage *image;
   int width, height;
   int x, y, y0;
+  int num_glyphs;
 } Atlas;
 
 struct _GskVulkanGlyphCache {
@@ -47,6 +48,7 @@ create_atlas (void)
   atlas->x = 1;
   atlas->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, atlas->width, atlas->height);
   atlas->image = NULL;
+  atlas->num_glyphs = 0;
 
   return atlas;
 }
@@ -191,6 +193,8 @@ add_to_cache (GskVulkanGlyphCache  *cache,
   atlas->x = atlas->x + value->draw_width + 1;
   atlas->y = MAX (atlas->y, atlas->y0 + value->draw_height + 1);
 
+  atlas->num_glyphs++;
+
   value->tx = (cg.x + value->draw_x) / atlas->width;
   value->ty = (cg.y + value->draw_y) / atlas->height;
   value->tw = (float)value->draw_width / atlas->width;
@@ -199,6 +203,24 @@ add_to_cache (GskVulkanGlyphCache  *cache,
   value->texture_index = i;
 
   g_clear_object (&atlas->image); /* force re-upload */
+
+#ifdef G_ENABLE_DEBUG
+  if (GSK_DEBUG_CHECK(GLYPH_CACHE))
+    {
+      gchar buffer[256];
+      g_print ("Glyph cache:\n");
+      for (i = 0; i < cache->atlases->len; i++)
+        {
+          atlas = g_ptr_array_index (cache->atlases, i);
+          g_print ("\tAtlas %d (%dx%d): %d glyphs, filled to %d, %d / %d\n",
+                   i, atlas->width, atlas->height, atlas->num_glyphs,
+                   atlas->x, atlas->y0, atlas->y);
+
+          snprintf (buffer, sizeof (buffer), "gsk-vulkan-glyph-cache-%d-%d.png", i, atlas->num_glyphs);
+          cairo_surface_write_to_png (atlas->surface, buffer);
+        }
+    }
+#endif
 }
 
 GskVulkanGlyphCache *


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