macos: assume monitor colorspace when drawing
authorChristian Hergert <christian@hergert.me>
Fri, 4 Feb 2022 17:46:10 +0000 (09:46 -0800)
committerChristian Hergert <christian@hergert.me>
Fri, 4 Feb 2022 17:46:10 +0000 (09:46 -0800)
When using software rendering w/ cairo, assume we're drawing in
the best-monitor's colorspace rather than RGB to avoid colorspace
conversions on every frame.

gdk/macos/GdkMacosCairoView.c

index d3573f59504987cc2cd4ebf6ed7b95edbb546604..ad8c72f649238893cce3cd208d5c4ada9a53b293 100644 (file)
@@ -28,6 +28,7 @@
 #import "GdkMacosCairoView.h"
 #import "GdkMacosCairoSubview.h"
 
+#include "gdkmacosmonitor-private.h"
 #include "gdkmacossurface-private.h"
 
 @implementation GdkMacosCairoView
@@ -78,6 +79,7 @@ release_surface_provider (void       *info,
       CGColorSpaceRef rgb;
       cairo_format_t format;
       CGBitmapInfo bitmap = kCGBitmapByteOrder32Host;
+      GdkMonitor *monitor;
       guint8 *framebuffer;
       size_t width;
       size_t height;
@@ -92,7 +94,8 @@ release_surface_provider (void       *info,
       rowstride = cairo_image_surface_get_stride (cairoSurface);
       width = cairo_image_surface_get_width (cairoSurface);
       height = cairo_image_surface_get_height (cairoSurface);
-      rgb = CGColorSpaceCreateDeviceRGB ();
+      monitor = _gdk_macos_surface_get_best_monitor ([self gdkSurface]);
+      rgb = _gdk_macos_monitor_copy_colorspace (GDK_MACOS_MONITOR (monitor));
 
       /* Assert that our image surface was created correctly with
        * 16-byte aligned pointers and strides. This is needed to