[gtk/master.win32: 10/10] gdkvulkancontext-win32.c: Implement ->begin_frame()




commit 11136082aae84d5579c6f440ca0284bb67cdcc5d
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Aug 3 18:43:46 2020 +0800

    gdkvulkancontext-win32.c: Implement ->begin_frame()
    
    By doing so, we ensure that resizes of windows will work on Vulkan renderer

 gdk/win32/gdkvulkancontext-win32.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/gdk/win32/gdkvulkancontext-win32.c b/gdk/win32/gdkvulkancontext-win32.c
index 607658dde9..c02ed44288 100644
--- a/gdk/win32/gdkvulkancontext-win32.c
+++ b/gdk/win32/gdkvulkancontext-win32.c
@@ -72,12 +72,44 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
   return result;
 }
 
+static void
+gdk_win32_vulkan_context_begin_frame (GdkDrawContext *draw_context,
+                                      cairo_region_t *update_area)
+{
+  GdkSurface *surface;
+  GdkWin32Surface *impl;
+  RECT queued_window_rect;
+
+  surface = gdk_draw_context_get_surface (draw_context);
+  impl = GDK_WIN32_SURFACE (surface);
+
+  gdk_win32_surface_get_queued_window_rect (surface,
+                                            gdk_surface_get_scale_factor (surface),
+                                            &queued_window_rect);
+
+  /* Apply queued resizes Vulkan windows before painting them
+   *  (we paint on the window DC directly, it must have the right size).
+   * Due to some poorly-understood issue delayed
+   * resizing of double-buffered windows can produce weird
+   * artefacts, so these are also resized before we paint.
+   */
+  if (impl->drag_move_resize_context.native_move_resize_pending)
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      gdk_win32_surface_apply_queued_move_resize (surface, queued_window_rect);
+    }
+
+  GDK_DRAW_CONTEXT_CLASS (gdk_win32_vulkan_context_parent_class)->begin_frame (draw_context, update_area);
+}
+
 static void
 gdk_win32_vulkan_context_class_init (GdkWin32VulkanContextClass *klass)
 {
   GdkVulkanContextClass *context_class = GDK_VULKAN_CONTEXT_CLASS (klass);
+  GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
 
   context_class->create_surface = gdk_win32_vulkan_context_create_surface;
+  draw_context_class->begin_frame = gdk_win32_vulkan_context_begin_frame;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]