From e7d038c027c3fd80f7f6714df3d6e1a5bb7b4968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 28 Feb 2023 16:25:42 +0100 Subject: iOS: Respect QSurfaceFormat::colorSpace() when using Metal Unlike on macOS, there's no colorSpace property on UIWindow or UIView, but CAMetalLayer has one, which allows us to tell Core Animation that the layer targets a specific color space, and Core Animation will then do the rest of the color matching to the target display. Now that we use Metal to flush raster content, this is even more useful. Task-number: QTBUG-108094 Pick-to: 6.5 Change-Id: Ib04b42d9baa296b608983db38faf0398430db093 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/ios/quiview.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 0510e6083a..979de6a313 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -108,6 +108,17 @@ inline ulong getTimeStamp(UIEvent *event) m_lastScrollDelta = CGPointZero; m_lastScrollCursorPos = CGPointZero; [self addGestureRecognizer:m_scrollGestureRecognizer]; + + if ([self.layer isKindOfClass:CAMetalLayer.class]) { + QWindow *window = self.platformWindow->window(); + if (QColorSpace colorSpace = window->format().colorSpace(); colorSpace.isValid()) { + QCFType iccData = colorSpace.iccProfile().toCFData(); + QCFType cgColorSpace = CGColorSpaceCreateWithICCData(iccData); + CAMetalLayer *metalLayer = static_cast(self.layer); + metalLayer.colorspace = cgColorSpace; + qCDebug(lcQpaWindow) << "Set" << self << "color space to" << metalLayer.colorspace; + } + } } return self; -- cgit v1.2.3