diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-02-28 16:25:42 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-03-02 12:51:14 +0100 |
commit | e7d038c027c3fd80f7f6714df3d6e1a5bb7b4968 (patch) | |
tree | af8ad69278c26964375e2e81e4d4b64a0536f5cb /src/plugins/platforms/ios | |
parent | d57ff481fcf870d2ff40b39782dfd2fcd9726c59 (diff) |
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 <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 11 |
1 files changed, 11 insertions, 0 deletions
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<CFDataRef> iccData = colorSpace.iccProfile().toCFData(); + QCFType<CGColorSpaceRef> cgColorSpace = CGColorSpaceCreateWithICCData(iccData); + CAMetalLayer *metalLayer = static_cast<CAMetalLayer *>(self.layer); + metalLayer.colorspace = cgColorSpace; + qCDebug(lcQpaWindow) << "Set" << self << "color space to" << metalLayer.colorspace; + } + } } return self; |