gtk/gsk/gskdebug.c
Christoph Reiter afc73c38ce Always parse GTK/GDK/GSK_DEBUG env vars and make some entries available in non-debug mode
Currently GTK can be built with G_ENABLE_DEBUG which enables various debug code and parsing
of those env vars, or without, which instead of parsing them prints a warning if they are set.
While building with G_ENABLE_DEBUG isn't strictly needed it's the only way to make GTK_DEBUG=interactive work,
which is a nice thing to have always.

This enables parsing of those env vars in any case and allows specific values being marked as also
available when not built with G_ENABLE_DEBUG (interactive for example). If not built with G_ENABLE_DEBUG
then all unavailable values will be marked as such in the help output and a note is added that
GTK needs to be built with G_ENABLE_DEBUG to use them, which should help discoverability.
2020-11-15 11:34:54 +01:00

57 lines
1.8 KiB
C

#include "gskdebugprivate.h"
#include "gdk/gdk-private.h"
static const GdkDebugKey gsk_debug_keys[] = {
{ "renderer", GSK_DEBUG_RENDERER, "General renderer information" },
{ "cairo", GSK_DEBUG_CAIRO, "Cairo renderer information" },
{ "opengl", GSK_DEBUG_OPENGL, "OpenGL renderer information" },
{ "vulkan", GSK_DEBUG_VULKAN, "Vulkan renderer information" },
{ "shaders", GSK_DEBUG_SHADERS, "Information about shaders" },
{ "surface", GSK_DEBUG_SURFACE, "Information about surfaces" },
{ "fallback", GSK_DEBUG_FALLBACK, "Information about fallbacks" },
{ "glyphcache", GSK_DEBUG_GLYPH_CACHE, "Information about glyph caching" },
{ "geometry", GSK_DEBUG_GEOMETRY, "Show borders (when using cairo)" },
{ "full-redraw", GSK_DEBUG_FULL_REDRAW, "Force full redraws" },
{ "sync", GSK_DEBUG_SYNC, "Sync after each frame" },
{ "vulkan-staging-image", GSK_DEBUG_VULKAN_STAGING_IMAGE, "Use a staging image for Vulkan texture upload" },
{ "vulkan-staging-buffer", GSK_DEBUG_VULKAN_STAGING_BUFFER, "Use a staging buffer for Vulkan texture upload" }
};
static guint gsk_debug_flags;
static void
init_debug_flags (void)
{
static volatile gsize gsk_debug_flags__set;
if (g_once_init_enter (&gsk_debug_flags__set))
{
gsk_debug_flags = gdk_parse_debug_var ("GSK_DEBUG",
gsk_debug_keys,
G_N_ELEMENTS (gsk_debug_keys));
g_once_init_leave (&gsk_debug_flags__set, TRUE);
}
}
gboolean
gsk_check_debug_flags (GskDebugFlags flags)
{
init_debug_flags ();
return (gsk_debug_flags & flags) != 0;
}
GskDebugFlags
gsk_get_debug_flags (void)
{
init_debug_flags ();
return gsk_debug_flags;
}
void
gsk_set_debug_flags (GskDebugFlags flags)
{
init_debug_flags ();
gsk_debug_flags = flags;
}