diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-19 23:59:44 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-20 23:26:14 -0400 |
commit | 6dbec5e4fc644c9932e76b3845d898418ae3f619 (patch) | |
tree | 070707d25a0cea0eedf0770b695d4fbf8d08a22d /gsk | |
parent | baeff2a49bc2b60f559d5fe2e9d3e6f4868c1d7c (diff) | |
download | gtk+-6dbec5e4fc644c9932e76b3845d898418ae3f619.tar.gz |
Add some debug output for the glyph cache
Print out some statistics and dump the glyph caches to a png,
for now.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gskdebug.c | 3 | ||||
-rw-r--r-- | gsk/gskdebugprivate.h | 3 | ||||
-rw-r--r-- | gsk/gskvulkanglyphcache.c | 22 |
3 files changed, 26 insertions, 2 deletions
diff --git a/gsk/gskdebug.c b/gsk/gskdebug.c index 94d40b728c..41d666899d 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 0f82c80586..c84bfe4d47 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 fc36b0adac..69181f6c9c 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 * |