[gtk+/wip/chergert/quartz-frame-clock: 137/138] wip: quartz: use colorspace from primary display



commit b1be2a70fd2655dbac6442d2efa10a413bb76c95
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 |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 2b4b2cc..d914ab2 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -3014,21 +3014,25 @@ static CGContextRef
 gdk_root_window_impl_quartz_get_context (GdkWindowImplQuartz *window,
                                          gboolean             antialias)
 {
-  CGColorSpaceRef colorspace;
+  CGColorSpaceRef colorSpace;
   CGContextRef cg_context;
   GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (window);
 
   if (GDK_WINDOW_DESTROYED (window_impl->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,
-                                      kCGImageAlphaPremultipliedLast);
-  CGColorSpaceRelease (colorspace);
+                                      1, 1, 8, 4, colorSpace,
+                                      kCGBitmapByteOrder32Host|kCGImageAlphaPremultipliedLast);
+
+  CGColorSpaceRelease (colorSpace);
 
   return cg_context;
 }


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