macOS: Don’t color convert the backing store

The backing store was assigned the sRGB color profile
as an unintended side effect of the QImage -> CGImage
conversion function refactoring in ac899f6d. This
caused Core Graphics to add a color convert step, which
in some cases caused performance issues.

Restore fast, previous behavior by assigning the target
display color profile to the backing store image.

Color correctness is still a goal, but we’ll add API
for it and make it opt-in.

Task-number: QTBUG-61384
Change-Id: Ia36d29404c64d8030a100f6a71816d84e484308b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Morten Johan Sørvig 2017-09-04 14:54:18 +02:00
parent a2a5b7a697
commit 4250993c42
1 changed files with 9 additions and 1 deletions

View File

@ -79,7 +79,15 @@ void QCocoaBackingStore::beginPaint(const QRegion &region)
void QCocoaBackingStore::endPaint()
{
QRasterBackingStore::endPaint();
m_cgImage = m_image.toCGImage();
// Prevent potentially costly color conversion by assiging the display
// color space to the backingstore image.
NSView *view = static_cast<QCocoaWindow *>(window()->handle())->view();
CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace;
QCFType<CGImageRef> displayColorSpaceImage =
CGImageCreateCopyWithColorSpace(m_image.toCGImage(), displayColorSpace);
m_cgImage = displayColorSpaceImage;
}
#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)