wayland: Factor out frame timings request code

Also call the code everywhere we draw and not just with Cairo.
This commit is contained in:
Benjamin Otte 2018-04-10 15:10:56 +02:00
parent e44bbeb558
commit adc0159bdb
4 changed files with 23 additions and 6 deletions

View File

@ -224,6 +224,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
context_wayland->egl_config);
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
if (display_wayland->have_egl_swap_buffers_with_damage && damage != NULL)
{

View File

@ -89,6 +89,7 @@ guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
guint *next_image_delay);
void gdk_wayland_surface_sync (GdkSurface *surface);
void gdk_wayland_surface_request_frame (GdkSurface *surface);
void _gdk_wayland_surface_register_dnd (GdkSurface *surface);
GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface,

View File

@ -513,12 +513,30 @@ on_frame_clock_before_paint (GdkFrameClock *clock,
}
}
void
gdk_wayland_surface_request_frame (GdkSurface *surface)
{
GdkSurfaceImplWayland *impl = GDK_SURFACE_IMPL_WAYLAND (surface->impl);
struct wl_callback *callback;
GdkFrameClock *clock;
if (impl->awaiting_frame)
return;
clock = gdk_surface_get_frame_clock (surface);
callback = wl_surface_frame (impl->display_server.wl_surface);
wl_callback_add_listener (callback, &frame_listener, surface);
_gdk_frame_clock_freeze (clock);
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
impl->awaiting_frame = TRUE;
}
static void
on_frame_clock_after_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkSurfaceImplWayland *impl = GDK_SURFACE_IMPL_WAYLAND (surface->impl);
struct wl_callback *callback;
if (!impl->pending_commit)
return;
@ -526,9 +544,7 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
if (surface->update_freeze_count > 0)
return;
callback = wl_surface_frame (impl->display_server.wl_surface);
wl_callback_add_listener (callback, &frame_listener, surface);
_gdk_frame_clock_freeze (clock);
gdk_wayland_surface_request_frame (surface);
/* Before we commit a new buffer, make sure we've backfilled
* undrawn parts from any old committed buffer
@ -551,8 +567,6 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
impl->pending_buffer_attached = FALSE;
impl->pending_commit = FALSE;
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
impl->awaiting_frame = TRUE;
g_signal_emit (impl, signals[COMMITTED], 0);
}

View File

@ -67,6 +67,7 @@ gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted, damage);
}