diff options
author | Morten Johan Sorvig <morten.sorvig@digia.com> | 2012-12-04 15:19:27 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-07 12:04:48 +0100 |
commit | 9650a5aa25b5750c571326380490c191c62fd6a1 (patch) | |
tree | 3ede6d0eda1d7eb3c2c6bd09915a47df4d668e4e /src/plugins/platforms/cocoa | |
parent | 2f6e967eb75e87e744ffbad6de89e76fc0bb0a37 (diff) |
Avoid backing store color space conversions.
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>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.mm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 008d9da2cf..0d0d2eb106 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -789,7 +789,21 @@ CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy) 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, |