[gtk/wip/nacho/quartz-colorspace: 104/104] wip: quartz: use colorspace from primary display



commit 12767093c60b4780978ac7d7caeb429141223ca6
Author: Christian Hergert <christian hergert me>
Date:   Wed Sep 30 18:37:16 2015 -0700

    wip: quartz: use colorspace from primary display
    
    Using the default RGB colorspace seems to go through colorspace
    conversion on tested macbook retina devices. Instead, default to the
    colorspace of the main display so that it does not incur the conversion
    cost on every frame.
    
    This probably requires the equivalent patch to cairo, I have not tested
    without it yet.

 gdk/quartz/gdkwindow-quartz.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 24503fdca9..0baaaca483 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -3135,18 +3135,21 @@ gdk_root_window_impl_quartz_get_context (GdkWindowImplQuartz *window,
 {
   CGColorSpaceRef colorspace;
   CGContextRef cg_context;
-  GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (window);
 
-  if (GDK_WINDOW_DESTROYED (window_impl->wrapper))
+  if (GDK_WINDOW_DESTROYED (window->wrapper))
     return NULL;
 
+  colorspace = CGDisplayCopyColorSpace (CGMainDisplayID ());
+  if (!colorspace)
+    colorspace = CGColorSpaceCreateDeviceRGB ();
+
   /* We do not have the notion of a root window on OS X.  We fake this
    * by creating a 1x1 bitmap and return a context to that.
    */
-  colorspace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
   cg_context = CGBitmapContextCreate (NULL,
                                       1, 1, 8, 4, colorspace,
-                                      (CGBitmapInfo)kCGImageAlphaPremultipliedLast);
+                                      (CGBitmapInfo)(kCGBitmapByteOrder32Host | 
kCGImageAlphaPremultipliedLast));
+
   CGColorSpaceRelease (colorspace);
 
   return cg_context;


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