From: Benjamin Otte Date: Fri, 30 Mar 2018 08:43:26 +0000 (+0200) Subject: x11: Make the frame clock work in GL and Vulkan X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~724 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7201e6312041bb5a778dfe47e944a9edda1e2e5a;p=gtk4.git x11: Make the frame clock work in GL and Vulkan --- diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index c5f104fde5..8eca015b1c 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -182,6 +182,8 @@ gdk_x11_gl_context_end_frame (GdkDrawContext *draw_context, } } + gdk_x11_surface_pre_damage (surface); + glXSwapBuffers (dpy, drawable); if (context_x11->do_frame_sync && info != NULL && display_x11->has_glx_video_sync) diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 54a101eb91..29385afb7e 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -229,8 +229,8 @@ set_sync_counter(Display *display, XSyncSetCounter (display, counter, sync_value); } -static void -surface_pre_damage (GdkSurface *surface) +void +gdk_x11_surface_pre_damage (GdkSurface *surface) { GdkSurface *toplevel_surface = gdk_surface_get_toplevel (surface); GdkSurfaceImplX11 *impl; @@ -257,7 +257,7 @@ on_surface_changed (void *data) GdkSurfaceImplX11 *impl = GDK_SURFACE_IMPL_X11 (surface->impl); if (impl->tracking_damage) - surface_pre_damage (surface); + gdk_x11_surface_pre_damage (surface); } /* We want to know when cairo drawing causes damage to the window, @@ -372,14 +372,14 @@ gdk_x11_surface_begin_frame (GdkSurface *surface, impl->toplevel->configure_counter_value = 0; - surface_pre_damage (surface); + gdk_x11_surface_pre_damage (surface); } else if (force_frame) { /* When mapping the surface, we really want to freeze the rendering of the surface by the compositor until we've actually painted something into the surface's buffer. */ - surface_pre_damage (surface); + gdk_x11_surface_pre_damage (surface); } else { @@ -1511,7 +1511,7 @@ surface_x11_resize (GdkSurface *surface, if (height < 1) height = 1; - surface_pre_damage (surface); + gdk_x11_surface_pre_damage (surface); XResizeWindow (GDK_SURFACE_XDISPLAY (surface), GDK_SURFACE_XID (surface), @@ -1547,7 +1547,7 @@ surface_x11_move_resize (GdkSurface *surface, if (height < 1) height = 1; - surface_pre_damage (surface); + gdk_x11_surface_pre_damage (surface); XMoveResizeWindow (GDK_SURFACE_XDISPLAY (surface), GDK_SURFACE_XID (surface), diff --git a/gdk/x11/gdksurface-x11.h b/gdk/x11/gdksurface-x11.h index 1beda132d8..07c67d6666 100644 --- a/gdk/x11/gdksurface-x11.h +++ b/gdk/x11/gdksurface-x11.h @@ -194,6 +194,8 @@ void _gdk_x11_surface_update_size (GdkSurfaceImplX11 *impl); void _gdk_x11_surface_set_surface_scale (GdkSurface *window, int scale); +void gdk_x11_surface_pre_damage (GdkSurface *surface); + G_END_DECLS #endif /* __GDK_SURFACE_X11_H__ */ diff --git a/gdk/x11/gdkvulkancontext-x11.c b/gdk/x11/gdkvulkancontext-x11.c index c59dbe3dec..733acd93b6 100644 --- a/gdk/x11/gdkvulkancontext-x11.c +++ b/gdk/x11/gdkvulkancontext-x11.c @@ -58,10 +58,25 @@ gdk_x11_vulkan_context_create_surface (GdkVulkanContext *context, surface); } +static void +gdk_x11_vulkan_context_end_frame (GdkDrawContext *context, + cairo_region_t *painted, + cairo_region_t *damage) +{ + GdkSurface *surface = gdk_draw_context_get_surface (context); + + gdk_x11_surface_pre_damage (surface); + + GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted, damage); +} + static void gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass) { GdkVulkanContextClass *context_class = GDK_VULKAN_CONTEXT_CLASS (klass); + GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass); + + draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame; context_class->create_surface = gdk_x11_vulkan_context_create_surface; }