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



commit c8df1afde20da7aeef2525f5853bb02a6b5a39bc
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 11 03:23:16 2022 -0800

    wip

 gdk/macos/gdkmacosbuffer-private.h    |  4 +---
 gdk/macos/gdkmacosbuffer.c            | 21 ++++++++-------------
 gdk/macos/gdkmacoscairocontext.c      |  4 ++++
 gdk/macos/gdkmacosglcontext-private.h |  2 ++
 gdk/macos/gdkmacosglcontext.c         |  2 ++
 gdk/macos/gdkmacossurface.c           |  4 +---
 6 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/gdk/macos/gdkmacosbuffer-private.h b/gdk/macos/gdkmacosbuffer-private.h
index 62e605c609..2c9ac0da90 100644
--- a/gdk/macos/gdkmacosbuffer-private.h
+++ b/gdk/macos/gdkmacosbuffer-private.h
@@ -24,7 +24,6 @@
 #include <Foundation/Foundation.h>
 #include <IOSurface/IOSurface.h>
 
-#include "gdkmacosdisplay.h"
 
 G_BEGIN_DECLS
 
@@ -32,8 +31,7 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GdkMacosBuffer, gdk_macos_buffer, GDK, MACOS_BUFFER, GObject)
 
-GdkMacosBuffer       *_gdk_macos_buffer_new              (GdkMacosDisplay *display,
-                                                          int              width,
+GdkMacosBuffer       *_gdk_macos_buffer_new              (int              width,
                                                           int              height,
                                                           double           device_scale,
                                                           int              bytes_per_element,
diff --git a/gdk/macos/gdkmacosbuffer.c b/gdk/macos/gdkmacosbuffer.c
index 1ec8554640..ace6a0e15d 100644
--- a/gdk/macos/gdkmacosbuffer.c
+++ b/gdk/macos/gdkmacosbuffer.c
@@ -30,7 +30,6 @@ struct _GdkMacosBuffer
 {
   GObject          parent_instance;
   cairo_region_t  *damage;
-  CGColorSpaceRef  colorspace;
   IOSurfaceRef     surface;
   int              lock_count;
   guint            bytes_per_element;
@@ -51,11 +50,10 @@ gdk_macos_buffer_dispose (GObject *object)
   if (self->lock_count != 0)
     g_critical ("Attempt to dispose %s while lock is held",
                 G_OBJECT_TYPE_NAME (self));
-  
+
   g_clear_pointer (&self->surface, CFRelease);
-  g_clear_pointer (&self->colorspace, CGColorSpaceRelease);
   g_clear_pointer (&self->damage, cairo_region_destroy);
-  
+
   G_OBJECT_CLASS (gdk_macos_buffer_parent_class)->dispose (object);
 }
 
@@ -63,7 +61,7 @@ static void
 gdk_macos_buffer_class_init (GdkMacosBufferClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  
+
   object_class->dispose = gdk_macos_buffer_dispose;
 }
 
@@ -120,21 +118,18 @@ create_surface (int   width,
 }
 
 GdkMacosBuffer *
-_gdk_macos_buffer_new (GdkMacosDisplay *display,
-                       int              width,
-                       int              height,
-                       double           device_scale,
-                       int              bytes_per_element,
-                       int              bits_per_pixel)
+_gdk_macos_buffer_new (int    width,
+                       int    height,
+                       double device_scale,
+                       int    bytes_per_element,
+                       int    bits_per_pixel)
 {
   GdkMacosBuffer *self;
 
-  g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
   g_return_val_if_fail (width > 0, NULL);
   g_return_val_if_fail (height > 0, NULL);
 
   self = g_object_new (GDK_TYPE_MACOS_BUFFER, NULL);
-  self->colorspace = CGColorSpaceCreateDeviceRGB ();
   self->bytes_per_element = bytes_per_element;
   self->bits_per_pixel = bits_per_pixel;
   self->surface = create_surface (width, height, bytes_per_element, &self->stride);
diff --git a/gdk/macos/gdkmacoscairocontext.c b/gdk/macos/gdkmacoscairocontext.c
index ccfd3a15ac..b4fdf717bd 100644
--- a/gdk/macos/gdkmacoscairocontext.c
+++ b/gdk/macos/gdkmacoscairocontext.c
@@ -186,6 +186,7 @@ static void
 _gdk_macos_cairo_context_end_frame (GdkDrawContext *draw_context,
                                     cairo_region_t *painted)
 {
+  GdkMacosBuffer *buffer;
   GdkSurface *surface;
 
   g_assert (GDK_IS_MACOS_CAIRO_CONTEXT (draw_context));
@@ -193,6 +194,9 @@ _gdk_macos_cairo_context_end_frame (GdkDrawContext *draw_context,
   surface = gdk_draw_context_get_surface (draw_context);
   _gdk_macos_surface_swap_buffers (GDK_MACOS_SURFACE (surface), painted);
 
+  buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
+  _gdk_macos_buffer_set_damage (buffer, NULL);
+
   [CATransaction commit];
 }
 
diff --git a/gdk/macos/gdkmacosglcontext-private.h b/gdk/macos/gdkmacosglcontext-private.h
index 92fcd7d40e..9d9b378b16 100644
--- a/gdk/macos/gdkmacosglcontext-private.h
+++ b/gdk/macos/gdkmacosglcontext-private.h
@@ -38,6 +38,8 @@ struct _GdkMacosGLContext
 {
   GdkGLContext parent_instance;
 
+  cairo_region_t *damage;
+
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   CGLContextObj cgl_context;
   G_GNUC_END_IGNORE_DEPRECATIONS
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index 04a62962d8..16fee8e3ee 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -554,6 +554,8 @@ gdk_macos_gl_context_dispose (GObject *gobject)
       CGLDestroyContext (cgl_context);
     }
 
+  g_clear_pointer (&self->damage, cairo_region_destroy);
+
   G_OBJECT_CLASS (gdk_macos_gl_context_parent_class)->dispose (gobject);
 }
 
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index b37f9cf50f..6a497828f2 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -874,7 +874,6 @@ _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self)
 static void
 gdk_macos_surface_update_buffers (GdkMacosSurface *self)
 {
-  GdkMacosDisplay *display;
   GdkMacosBuffer *buffer;
   double scale;
   guint width;
@@ -891,8 +890,7 @@ gdk_macos_surface_update_buffers (GdkMacosSurface *self)
    * handles opaque regions for the compositor, so using 3-byte/24-bit is
    * not a necessary optimization.
    */
-  display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self)));
-  buffer = _gdk_macos_buffer_new (display, width, height, scale, 4, 32);
+  buffer = _gdk_macos_buffer_new (width, height, scale, 4, 32);
 
   /* If we failed, just keep the old buffer around. */
   if (buffer != NULL)


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