We want the Qt backing store to be in the device color
space by default. This will avoid colour space conversions
when blitting it to screen, at the cost of a potential
loss in color accuracy.
As it turns out, CGColorSpaceCreateDeviceRGB no longer
crates a device color space but rather a generic color
space. (Since 10.4). Create the color space with a system
profile instead.
Accurate color representation needs to be supported
at some point, but this fast path should be the
default.
Change-Id: I7ebb77b36f81f66119d8c2ef464723401ec1d1e8
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
NULL,
false);
} else {
- CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
+ // Try get a device color space. Using the device color space means
+ // that the CGImage can be drawn to screen without per-pixel color
+ // space conversion, at the cost of less color accuracy.
+ CGColorSpaceRef cgColourSpaceRef = 0;
+ CMProfileRef sysProfile;
+ if (CMGetSystemProfile(&sysProfile) == noErr)
+ {
+ cgColourSpaceRef = CGColorSpaceCreateWithPlatformColorSpace(sysProfile);
+ CMCloseProfile(sysProfile);
+ }
+
+ // Fall back to Generic RGB if a profile was not found.
+ if (!cgColourSpaceRef)
+ cgColourSpaceRef = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+
cgImage = CGImageCreate(width,
height,
colorBufferSize,