gsk: Use the new debug macros

This commit is contained in:
Matthias Clasen 2022-09-22 21:36:50 -04:00
parent 4d08eb264d
commit 9818ec4ad9
9 changed files with 57 additions and 51 deletions

View File

@ -74,9 +74,9 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO) if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
{ {
GSK_NOTE (GLYPH_CACHE, GSK_DEBUG (GLYPH_CACHE,
g_message ("Dropping atlas %d (%g.2%% old)", i, "Dropping atlas %d (%g.2%% old)", i,
100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas))); 100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas));
if (removed == NULL) if (removed == NULL)
removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free); removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
g_ptr_array_add (removed, g_ptr_array_steal_index (self->atlases, i - 1)); g_ptr_array_add (removed, g_ptr_array_steal_index (self->atlases, i - 1));
@ -122,14 +122,14 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
} }
} }
GSK_NOTE (GLYPH_CACHE, g_message ("%s: Dropped %d individual items", GSK_DEBUG (GLYPH_CACHE, "%s: Dropped %d individual items",
G_OBJECT_TYPE_NAME (self), G_OBJECT_TYPE_NAME (self),
dropped); dropped);
g_message ("%s: %d items cached (%d atlased, %d individually)", GSK_DEBUG (GLYPH_CACHE, "%s: %d items cached (%d atlased, %d individually)",
G_OBJECT_TYPE_NAME (self), G_OBJECT_TYPE_NAME (self),
g_hash_table_size (self->hash_table), g_hash_table_size (self->hash_table),
atlased, atlased,
g_hash_table_size (self->hash_table) - atlased)); g_hash_table_size (self->hash_table) - atlased);
if (dropped > 0) if (dropped > 0)
gsk_gl_texture_library_clear_cache (self); gsk_gl_texture_library_clear_cache (self);
@ -139,17 +139,20 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
g_clear_pointer (&removed, g_ptr_array_unref); g_clear_pointer (&removed, g_ptr_array_unref);
} }
GSK_NOTE (GLYPH_CACHE, { #ifdef G_ENABLE_DEBUG
static gint64 last_message; if (GSK_DEBUG_CHECK (GLYPH_CACHE))
gint64 now = g_get_monotonic_time (); {
if (now - last_message > G_USEC_PER_SEC) static gint64 last_message;
{ gint64 now = g_get_monotonic_time ();
last_message = now; if (now - last_message > G_USEC_PER_SEC)
g_message ("%s contains %d atlases", {
G_OBJECT_TYPE_NAME (self), last_message = now;
self->atlases->len); gdk_debug_message ("%s contains %d atlases",
} G_OBJECT_TYPE_NAME (self),
}); self->atlases->len);
}
}
#endif
return ret; return ret;
} }

View File

@ -1,3 +1,5 @@
#include "config.h"
#include "gskdebugprivate.h" #include "gskdebugprivate.h"
#include "gdk/gdk-private.h" #include "gdk/gdk-private.h"

View File

@ -648,10 +648,10 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
if (gsk_renderer_realize (renderer, surface, &error)) if (gsk_renderer_realize (renderer, surface, &error))
{ {
GSK_RENDERER_NOTE (renderer, RENDERER, GSK_RENDERER_DEBUG (renderer, RENDERER,
g_message ("Using renderer of type '%s' for surface '%s'\n", "Using renderer of type '%s' for surface '%s'",
G_OBJECT_TYPE_NAME (renderer), G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface))); G_OBJECT_TYPE_NAME (surface));
return renderer; return renderer;
} }

View File

@ -439,9 +439,9 @@ gsk_render_node_draw (GskRenderNode *node,
cairo_save (cr); cairo_save (cr);
GSK_NOTE (CAIRO, g_message ("Rendering node %s[%p]", GSK_DEBUG (CAIRO, "Rendering node %s[%p]",
g_type_name_from_instance ((GTypeInstance *) node), g_type_name_from_instance ((GTypeInstance *) node),
node)); node);
GSK_RENDER_NODE_GET_CLASS (node)->draw (node, cr); GSK_RENDER_NODE_GET_CLASS (node)->draw (node, cr);

View File

@ -2881,10 +2881,10 @@ gsk_transform_node_draw (GskRenderNode *node,
gsk_transform_to_2d (self->transform, &xx, &yx, &xy, &yy, &dx, &dy); gsk_transform_to_2d (self->transform, &xx, &yx, &xy, &yy, &dx, &dy);
cairo_matrix_init (&ctm, xx, yx, xy, yy, dx, dy); cairo_matrix_init (&ctm, xx, yx, xy, yy, dx, dy);
GSK_NOTE (CAIRO, g_message ("CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }", GSK_DEBUG (CAIRO, "CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }",
ctm.xx, ctm.yx, ctm.xx, ctm.yx,
ctm.xy, ctm.yy, ctm.xy, ctm.yy,
ctm.x0, ctm.y0)); ctm.x0, ctm.y0);
if (xx * yy == xy * yx) if (xx * yy == xy * yx)
{ {
/* broken matrix here. This can happen during transitions /* broken matrix here. This can happen during transitions

View File

@ -309,8 +309,8 @@ upload_dirty_glyphs (GskVulkanGlyphCache *cache,
for (l = atlas->dirty_glyphs, i = 0; l; l = l->next, i++) for (l = atlas->dirty_glyphs, i = 0; l; l = l->next, i++)
render_glyph (atlas, (DirtyGlyph *)l->data, &regions[i]); render_glyph (atlas, (DirtyGlyph *)l->data, &regions[i]);
GSK_RENDERER_NOTE (cache->renderer, GLYPH_CACHE, GSK_RENDERER_DEBUG (cache->renderer, GLYPH_CACHE,
g_message ("uploading %d glyphs to cache", num_regions)); "uploading %d glyphs to cache", num_regions);
gsk_vulkan_image_upload_regions (atlas->image, uploader, num_regions, regions); gsk_vulkan_image_upload_regions (atlas->image, uploader, num_regions, regions);
@ -471,8 +471,9 @@ gsk_vulkan_glyph_cache_begin_frame (GskVulkanGlyphCache *cache)
if (atlas->old_pixels > MAX_OLD * atlas->width * atlas->height) if (atlas->old_pixels > MAX_OLD * atlas->width * atlas->height)
{ {
GSK_RENDERER_NOTE(cache->renderer, GLYPH_CACHE, GSK_RENDERER_DEBUG (cache->renderer, GLYPH_CACHE,
g_message ("Dropping atlas %d (%g.2%% old)", i, 100.0 * (double)atlas->old_pixels / (double)(atlas->width * atlas->height))); "Dropping atlas %d (%g.2%% old)",
i, 100.0 * (double)atlas->old_pixels / (double)(atlas->width * atlas->height));
g_ptr_array_remove_index (cache->atlases, i); g_ptr_array_remove_index (cache->atlases, i);
drops[i] = 1; drops[i] = 1;
@ -501,5 +502,5 @@ gsk_vulkan_glyph_cache_begin_frame (GskVulkanGlyphCache *cache)
} }
} }
GSK_RENDERER_NOTE(cache->renderer, GLYPH_CACHE, g_message ("Dropped %d glyphs", dropped)); GSK_RENDERER_DEBUG (cache->renderer, GLYPH_CACHE, "Dropped %d glyphs", dropped);
} }

View File

@ -25,7 +25,7 @@ gsk_vulkan_handle_result (VkResult res,
{ {
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
GSK_NOTE (VULKAN,g_printerr ("%s(): %s (%d)\n", called_function, gdk_vulkan_strerror (res), res)); GSK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
} }
return res; return res;
} }

View File

@ -235,7 +235,7 @@ gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
} }
#define FALLBACK(...) G_STMT_START { \ #define FALLBACK(...) G_STMT_START { \
GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, g_message (__VA_ARGS__)); \ GSK_RENDERER_DEBUG (gsk_vulkan_render_get_renderer (render), FALLBACK, __VA_ARGS__); \
goto fallback; \ goto fallback; \
}G_STMT_END }G_STMT_END
@ -763,9 +763,9 @@ gsk_vulkan_render_pass_get_node_as_texture (GskVulkanRenderPass *self,
} }
} }
GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, g_message ("Node as texture not implemented for this case. Using %gx%g fallback surface", GSK_RENDERER_DEBUG (gsk_vulkan_render_get_renderer (render), FALLBACK, "Node as texture not implemented for this case. Using %gx%g fallback surface",
ceil (bounds->size.width), ceil (bounds->size.width),
ceil (bounds->size.height))); ceil (bounds->size.height));
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
{ {
GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render)); GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render));
@ -816,13 +816,13 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
node = op->node; node = op->node;
GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, GSK_RENDERER_DEBUG (gsk_vulkan_render_get_renderer (render), FALLBACK,
g_message ("Upload op=%s, node %s[%p], bounds %gx%g", "Upload op=%s, node %s[%p], bounds %gx%g",
op->type == GSK_VULKAN_OP_FALLBACK_CLIP ? "fallback-clip" : op->type == GSK_VULKAN_OP_FALLBACK_CLIP ? "fallback-clip" :
(op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : "fallback"), (op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : "fallback"),
g_type_name_from_instance ((GTypeInstance *) node), node, g_type_name_from_instance ((GTypeInstance *) node), node,
ceil (node->bounds.size.width), ceil (node->bounds.size.width),
ceil (node->bounds.size.height))); ceil (node->bounds.size.height));
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
{ {
GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render)); GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render));

View File

@ -65,7 +65,7 @@ gsk_vulkan_shader_new_from_resource (GdkVulkanContext *context,
g_free (path); g_free (path);
if (bytes == NULL) if (bytes == NULL)
{ {
GSK_NOTE (VULKAN, g_message ("Error loading shader data: %s", local_error->message)); GSK_DEBUG (VULKAN, "Error loading shader data: %s", local_error->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
return NULL; return NULL;
} }