When using the colorspace returned from CGColorSpaceCreateDeviceRGB(), a colorspace transformation will be applied on any CGContextDrawImage() call, leading to 5-6x worse performance than blitting without this transform.
To avoid this colorspace transformation, we have been using the colorspace created with the system monitor profile:
CMProfileRef smp = 0;
if (CMGetSystemProfile(&smp) == noErr)
{
colorSpace = CGColorSpaceCreateWithPlatformColorSpace(smp);
CMCloseProfile(smp);
}
else
colorSpace = CGColorSpaceCreateDeviceRGB();
The above works well and completely disables the colorspace transformations for CGContextDrawImage().
CMGetSystemProfile has been marked deprecated since 10.6, but since we haven't found any other possibility to avoid these colorspace transformations, we have kept it in our code for high-performance blitting.
In 10.11 SDK, the ColorSpace API CMGetSystemProfile() is removed. Is there a suitable replacement, or an alternative method on how to disable colorspace transformations?
To answer my own question,
the solution that I ended up using is to get the color space from the main display ID, using the functions CGDisplayCopyColorSpace and CGMainDisplayID:
colorSpace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
if (!colorSpace)
colorSpace = CGColorSpaceCreateDeviceRGB();
This is available with 10.11 SDK, and will create a colorspace which avoids colorspace transformations with calls to CGContextDrawImage().
Analyzing the call stack with Instruments shows a callstack that is identical to the previous code we've been using.