From 7bd39e19b8c63f96aac63fcbf234dfddfd3b9626 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 14 Jul 2020 09:40:34 -0400 Subject: x11: don't set up frame sync fence on unsupported compositors Not all compositors support _NET_WM_FRAME_DRAWN. In cases where teh compositor doesn't support _NET_WM_FRAME_DRAWN we don't need to do all the fancy damage tracking and fence watching. Furthermore, if the compositor doesn't support frame drawn, it's possible that one frame will start before the previous frame has made it through the pipeline, leading to a blown assertion. This commit side steps the unnecessary code an associated assertion when _NET_WM_FRAME_DRAWN isn't supported. May help with https://gitlab.gnome.org/GNOME/gtk/-/issues/2927 --- gdk/x11/gdkglcontext-x11.c | 2 +- gdk/x11/gdksurface-x11.c | 8 ++++---- gdk/x11/gdksurface-x11.h | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index 37efcf6c10..56d8eff1ea 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -184,7 +184,7 @@ gdk_x11_gl_context_end_frame (GdkDrawContext *draw_context, gdk_x11_surface_pre_damage (surface); #ifdef HAVE_XDAMAGE - if (context_x11->xdamage != 0) + if (context_x11->xdamage != 0 && _gdk_x11_surface_syncs_frames (surface)) { g_assert (context_x11->frame_fence == 0); diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 54bf26aae6..2567d7e765 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -360,8 +360,8 @@ gdk_x11_surface_begin_frame (GdkSurface *surface, } } -static gboolean -should_sync_frame_drawing (GdkSurface *surface) +gboolean +_gdk_x11_surface_syncs_frames (GdkSurface *surface) { GdkX11Surface *impl = GDK_X11_SURFACE (surface); @@ -395,7 +395,7 @@ static void maybe_sync_counter_for_end_frame (GdkSurface *surface) { GdkX11Surface *impl = GDK_X11_SURFACE (surface); - gboolean frame_sync_negotiated = should_sync_frame_drawing (surface); + gboolean frame_sync_negotiated = _gdk_x11_surface_syncs_frames (surface); gboolean frame_done_painting = !impl->toplevel->frame_pending; #ifdef HAVE_XDAMAGE @@ -478,7 +478,7 @@ gdk_x11_surface_end_frame (GdkSurface *surface) maybe_sync_counter_for_end_frame (surface); - if (should_sync_frame_drawing (surface)) + if (_gdk_x11_surface_syncs_frames (surface)) { impl->toplevel->frame_pending = TRUE; gdk_surface_freeze_updates (surface); diff --git a/gdk/x11/gdksurface-x11.h b/gdk/x11/gdksurface-x11.h index 5715c2f21d..6fc7afd07d 100644 --- a/gdk/x11/gdksurface-x11.h +++ b/gdk/x11/gdksurface-x11.h @@ -179,6 +179,7 @@ GdkCursor *_gdk_x11_surface_get_cursor (GdkSurface *window); void _gdk_x11_surface_update_size (GdkX11Surface *impl); void _gdk_x11_surface_set_surface_scale (GdkSurface *window, int scale); +gboolean _gdk_x11_surface_syncs_frames (GdkSurface *surface); void gdk_x11_surface_pre_damage (GdkSurface *surface); @@ -188,6 +189,7 @@ void gdk_x11_surface_move (GdkSurface *surface, void gdk_x11_surface_check_monitor (GdkSurface *surface, GdkMonitor *monitor); + G_END_DECLS #endif /* __GDK_X11_SURFACE__ */ -- cgit v1.2.1