x11: Make the frame clock work in GL and Vulkan

This commit is contained in:
Benjamin Otte 2018-03-30 10:43:26 +02:00
parent 70198e21ee
commit 7201e63120
4 changed files with 26 additions and 7 deletions

View File

@ -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)

View File

@ -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),

View File

@ -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__ */

View File

@ -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;
}