wayland: Implement empty_frame in draw contexts

This commit is contained in:
Matthias Clasen 2023-11-09 22:41:22 +01:00
parent 9eef566b54
commit 00d7d4b17b
3 changed files with 53 additions and 0 deletions

View File

@ -194,6 +194,23 @@ gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
self->paint_surface = NULL;
}
static void
gdk_wayland_cairo_context_empty_frame (GdkDrawContext *draw_context)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!impl->has_pending_subsurface_commits)
return;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
}
static void
gdk_wayland_cairo_context_clear_all_cairo_surfaces (GdkWaylandCairoContext *self)
{
@ -241,6 +258,7 @@ gdk_wayland_cairo_context_class_init (GdkWaylandCairoContextClass *klass)
draw_context_class->begin_frame = gdk_wayland_cairo_context_begin_frame;
draw_context_class->end_frame = gdk_wayland_cairo_context_end_frame;
draw_context_class->empty_frame = gdk_wayland_cairo_context_empty_frame;
draw_context_class->surface_resized = gdk_wayland_cairo_context_surface_resized;
cairo_context_class->cairo_create = gdk_wayland_cairo_context_cairo_create;

View File

@ -83,6 +83,22 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_notify_committed (surface);
}
static void
gdk_wayland_gl_context_empty_frame (GdkDrawContext *draw_context)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (impl->has_pending_subsurface_commits)
{
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
}
}
static void
gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
{
@ -91,6 +107,7 @@ gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
draw_context_class->begin_frame = gdk_wayland_gl_context_begin_frame;
draw_context_class->end_frame = gdk_wayland_gl_context_end_frame;
draw_context_class->empty_frame = gdk_wayland_gl_context_empty_frame;
context_class->backend_type = GDK_GL_EGL;
}

View File

@ -28,6 +28,7 @@
#include "gdkwaylanddisplay.h"
#include "gdkwaylandsurface.h"
#include "gdksurface-wayland-private.h"
#include "gdkprivate-wayland.h"
G_DEFINE_TYPE (GdkWaylandVulkanContext, gdk_wayland_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
@ -72,6 +73,22 @@ gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
gdk_wayland_surface_notify_committed (surface);
}
static void
gdk_vulkan_context_wayland_empty_frame (GdkDrawContext *context)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!impl->has_pending_subsurface_commits)
return;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
}
static void
gdk_wayland_vulkan_context_class_init (GdkWaylandVulkanContextClass *klass)
{
@ -80,6 +97,7 @@ gdk_wayland_vulkan_context_class_init (GdkWaylandVulkanContextClass *klass)
vulkan_context_class->create_surface = gdk_wayland_vulkan_context_create_surface;
draw_context_class->end_frame = gdk_vulkan_context_wayland_end_frame;
draw_context_class->empty_frame = gdk_vulkan_context_wayland_empty_frame;
}
static void