gdk: Add GDK_DEBUG=no-vsync

That turns off waiting and freezing in the frame clock and in
surfaces and triggers redraws asap.
This commit is contained in:
Benjamin Otte
2023-05-09 14:55:54 +02:00
parent fa42e02a76
commit 02e2a6f311
4 changed files with 13 additions and 1 deletions

View File

@@ -132,6 +132,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer", TRUE },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings", TRUE },
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible", TRUE },
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)", TRUE },
};

View File

@@ -52,6 +52,7 @@ typedef enum {
GDK_DEBUG_VULKAN_VALIDATE = 1 << 23,
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 24,
GDK_DEBUG_HIGH_DEPTH = 1 << 25,
GDK_DEBUG_NO_VSYNC = 1 << 26,
} GdkDebugFlags;
extern guint _gdk_debug_flags;

View File

@@ -280,6 +280,9 @@ gdk_frame_clock_idle_is_frozen (GdkFrameClockIdle *self)
{
GdkFrameClockIdlePrivate *priv = self->priv;
if (GDK_DEBUG_CHECK (NO_VSYNC))
return FALSE;
return priv->freeze_count > 0;
}
@@ -317,7 +320,8 @@ maybe_start_idle (GdkFrameClockIdle *self,
{
guint min_interval = 0;
if (priv->min_next_frame_time != 0)
if (priv->min_next_frame_time != 0 &&
!GDK_DEBUG_CHECK (NO_VSYNC))
{
gint64 now = g_get_monotonic_time ();
gint64 min_interval_us = MAX (priv->min_next_frame_time, now) - now;

View File

@@ -1530,6 +1530,9 @@ gdk_surface_freeze_updates (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_DEBUG_CHECK (NO_VSYNC))
return;
surface->update_freeze_count++;
if (surface->update_freeze_count == 1)
_gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
@@ -1562,6 +1565,9 @@ gdk_surface_thaw_updates (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_DEBUG_CHECK (NO_VSYNC))
return;
g_return_if_fail (surface->update_freeze_count > 0);
if (--surface->update_freeze_count == 0)