diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-01-26 17:22:34 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-02-15 16:27:19 +0100 |
commit | ef378898454964ce4d66d2656d2d5e4c7ac69b22 (patch) | |
tree | 644651de193024a3d23e6cbbd00a42c546f22ead /src/plugins/platforms/cocoa/qcocoawindow.mm | |
parent | 775a57f26682867e183d26863d85eb22a563cdbd (diff) |
macOS: Expand and tighten plumbing of QWindow's requested color space
A QWindow can have a requested target color space via its QSurfaceFormat.
This allows users who know what color space their source material is in,
or who do their own color matching, to ensure a consistent target color
space.
In the past we plumbed this to NSWindow's colorSpace property. This meant
that you could only have one color space per top level, even if child
windows were in play, and we could only set the color space if we were
the ones creating the NSWindow, failing the color space request in cases
where the window was embedded in a non-Qt window hierarchy.
We now store the requested color space in our QNSView, and propagate it
to both the IOSurfaces we use in QCALayerBackingStore, and to the view's
layer, in case it's a CAMetalLayer. We also pick up any changes to the
backing properties of the view, and ensure we update the color space
accordingly.
We still propagate the color space to NSWindow, as for OpenGL we don't
use CAOpenGLLayer (which has a colorSpace property), but instead use
NSOpenGLContext. This is not something we're going to change, so as
a workaround we set the NSWindow color space, which does affect GL
drawing via NSOpenGLContext. The granular color spaces we set on
the IOSurfaces and CAMetalLayer will override the NSWindow state.
Pick-to: 6.7
Change-Id: I5d9765d95140b8523ee09f70ff09a8c9400ffdc7
Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 14c72fd91a..4a245a0f8a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1812,11 +1812,15 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel) applyContentBorderThickness(nsWindow); - if (QColorSpace colorSpace = format().colorSpace(); colorSpace.isValid()) { - NSData *iccData = colorSpace.iccProfile().toNSData(); - nsWindow.colorSpace = [[[NSColorSpace alloc] initWithICCProfileData:iccData] autorelease]; - qCDebug(lcQpaDrawing) << "Set" << this << "color space to" << nsWindow.colorSpace; - } + // We propagate the view's color space granulary to both the IOSurfaces + // used for QSurface::RasterSurface, as well as the CAMetalLayer used for + // QSurface::MetalSurface, but for QSurface::OpenGLSurface we don't have + // that option as we use NSOpenGLContext instead of CAOpenGLLayer. As a + // workaround we set the NSWindow's color space, which affects GL drawing + // with NSOpenGLContext as well. This does not conflict with the granular + // modifications we do to each surface for raster or Metal. + if (auto *qtView = qnsview_cast(m_view)) + nsWindow.colorSpace = qtView.colorSpace; return nsWindow; } |