[gtk/wip/chergert/macos-iosurface] fixup damage



commit 12517c63cd5e64c7855a095913299a35806b3577
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 11 03:31:49 2022 -0800

    fixup damage

 gdk/macos/gdkmacosbuffer-private.h |  2 ++
 gdk/macos/gdkmacosglcontext.c      | 21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/gdk/macos/gdkmacosbuffer-private.h b/gdk/macos/gdkmacosbuffer-private.h
index 2c9ac0da90..0b7b12875a 100644
--- a/gdk/macos/gdkmacosbuffer-private.h
+++ b/gdk/macos/gdkmacosbuffer-private.h
@@ -24,6 +24,8 @@
 #include <Foundation/Foundation.h>
 #include <IOSurface/IOSurface.h>
 
+#include <cairo.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index 16fee8e3ee..25960026a8 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -431,6 +431,9 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
 
   surface = gdk_draw_context_get_surface (context);
 
+  g_clear_pointer (&self->damage, cairo_region_destroy);
+  self->damage = cairo_region_copy (region);
+
   /* Begin a Core Animation transaction so that all changes we
    * make within the window are seen atomically.
    */
@@ -483,6 +486,16 @@ gdk_macos_gl_context_end_frame (GdkDrawContext *context,
   [CATransaction commit];
 }
 
+static void
+gdk_macos_gl_context_surface_resized (GdkDrawContext *draw_context)
+{
+  GdkMacosGLContext *self = (GdkMacosGLContext *)draw_context;
+
+  g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
+
+  g_clear_pointer (&self->damage, cairo_region_destroy);
+}
+
 static gboolean
 gdk_macos_gl_context_clear_current (GdkGLContext *context)
 {
@@ -532,7 +545,12 @@ gdk_macos_gl_context_make_current (GdkGLContext *context,
 static cairo_region_t *
 gdk_macos_gl_context_get_damage (GdkGLContext *context)
 {
-  return cairo_region_create ();
+  GdkMacosGLContext *self = (GdkMacosGLContext *)context;
+
+  if (self->damage)
+    return cairo_region_copy (self->damage);
+
+  return GDK_GL_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->get_damage (context);
 }
 
 static void
@@ -570,6 +588,7 @@ gdk_macos_gl_context_class_init (GdkMacosGLContextClass *klass)
 
   draw_context_class->begin_frame = gdk_macos_gl_context_begin_frame;
   draw_context_class->end_frame = gdk_macos_gl_context_end_frame;
+  draw_context_class->surface_resized = gdk_macos_gl_context_surface_resized;
 
   gl_class->get_damage = gdk_macos_gl_context_get_damage;
   gl_class->clear_current = gdk_macos_gl_context_clear_current;


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