rhi: Pick up HDR maxColorComponentValue from UIScreen if available

Although QRhiSwapChainHdrInfo uses 'max' for this value, it's used
by Qt Multimedia's QVideoWindowPrivate::render() as the current
maximum, so we need to reflect UIScreen's currentEDRHeadroom
rather than potentialEDRHeadroom (the absolute max), the same
way we reflect maximumExtendedDynamicRangeColorComponentValue
and not maximumPotentialExtendedDynamicRangeColorComponentValue
from NSScreen.

As we don't support HDRExtendedSrgbLinear on < iOS 16 there
is no point in providing a heuristic fallback based on the
iPhone 12 spec.

Change-Id: If071bb64f269ce16886206df05eb9f27d260bf15
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 74319d05b1e8e2b5dcf226ef11bc66776460fa3f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-06-07 14:05:17 +02:00 committed by Qt Cherry-pick Bot
parent 0c6c9ec6a2
commit 8133a6e2af

View File

@ -6331,22 +6331,24 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo()
{
QRhiSwapChainHdrInfo info;
info.limitsType = QRhiSwapChainHdrInfo::ColorComponentValue;
if (m_format == SDR) {
info.limits.colorComponentValue.maxColorComponentValue = 1;
return info;
info.limits.colorComponentValue.maxColorComponentValue = 1;
info.isHardCodedDefaults = true;
if (m_format != SDR && m_window) {
// Must use m_window, not window, given this may be called before createOrResize().
#ifdef Q_OS_MACOS
NSView *view = reinterpret_cast<NSView *>(m_window->winId());
info.limits.colorComponentValue.maxColorComponentValue = view.window.screen.maximumExtendedDynamicRangeColorComponentValue;
info.isHardCodedDefaults = false;
#else
if (@available(iOS 16.0, *)) {
UIView *view = reinterpret_cast<UIView *>(m_window->winId());
info.limits.colorComponentValue.maxColorComponentValue = view.window.windowScene.screen.currentEDRHeadroom;
info.isHardCodedDefaults = false;
}
#endif
}
#ifdef Q_OS_MACOS
info.isHardCodedDefaults = false;
// Must use m_window, not window, given this may be called before createOrResize().
NSView *view = reinterpret_cast<NSView *>(m_window->winId());
info.limits.colorComponentValue.maxColorComponentValue = view.window.screen.maximumExtendedDynamicRangeColorComponentValue;
#else
// ### Fixme: Maybe retrieve the brightness from the screen and if we're not at full brightness we might be able to do more.
// For now, assume 2, in line with iPhone 12 specs that claim 625 nits max brightness and 1200 nits max HDR brightness.
info.isHardCodedDefaults = true;
info.limits.colorComponentValue.maxColorComponentValue = 2;
#endif
return info;
}