cocoa-cb: guard color spaces that are only available on 10.15.4 upwards

This commit is contained in:
der richter 2024-06-15 15:18:43 +02:00
parent e3a290b618
commit 55241da4ad
4 changed files with 20 additions and 1 deletions

View File

@ -1575,6 +1575,12 @@ if features['cocoa'] and features['swift']
'video/out/mac/window.swift')
endif
macos_10_15_4_features = get_option('macos-10-15-4-features').require(
macos_sdk_version.version_compare('>= 10.15.4'),
error_message: 'A macos sdk version >= 10.15.4 could not be found!',
)
features += {'macos-10-15-4-features': macos_10_15_4_features.allowed()}
macos_11_features = get_option('macos-11-features').require(
macos_sdk_version.version_compare('>= 11'),
error_message: 'A macos sdk version >= 11 could not be found!',

View File

@ -106,6 +106,7 @@ option('videotoolbox-pl', type: 'feature', value: 'auto', description: 'Videotoo
option('vulkan-interop', type: 'feature', value: 'auto', description: 'Vulkan graphics interop')
# macOS features
option('macos-10-15-4-features', type: 'feature', value: 'auto', description: 'macOS 10.15.4 SDK Features')
option('macos-11-features', type: 'feature', value: 'auto', description: 'macOS 11 SDK Features')
option('macos-12-features', type: 'feature', value: 'auto', description: 'macOS 12 SDK Features')
option('macos-cocoa-cb', type: 'feature', value: 'auto', description: 'macOS libmpv backend')

View File

@ -19,6 +19,10 @@ if get_option('optimization') != '0'
swift_flags += '-O'
endif
if macos_10_15_4_features.allowed()
swift_flags += ['-D', 'HAVE_MACOS_10_15_4_FEATURES']
endif
if macos_11_features.allowed()
swift_flags += ['-D', 'HAVE_MACOS_11_FEATURES']
endif

View File

@ -135,7 +135,6 @@ class CocoaCB: Common, EventSubscriber {
case MAC_CSP_AUTO: return colorSpace
case MAC_CSP_DISPLAY_P3: return CGColorSpace(name: CGColorSpace.displayP3)
case MAC_CSP_DISPLAY_P3_HLG: return CGColorSpace(name: CGColorSpace.displayP3_HLG)
case MAC_CSP_DISPLAY_P3_PQ: return CGColorSpace(name: CGColorSpace.displayP3_PQ)
case MAC_CSP_DCI_P3: return CGColorSpace(name: CGColorSpace.dcip3)
case MAC_CSP_BT_2020: return CGColorSpace(name: CGColorSpace.itur_2020)
case MAC_CSP_BT_709: return CGColorSpace(name: CGColorSpace.itur_709)
@ -146,6 +145,15 @@ class CocoaCB: Common, EventSubscriber {
default: break
}
#if HAVE_MACOS_10_15_4_FEATURES
if #available(macOS 10.15.4, *) {
switch outputCsp {
case MAC_CSP_DISPLAY_P3_PQ: return CGColorSpace(name: CGColorSpace.displayP3_PQ)
default: break
}
}
#endif
#if HAVE_MACOS_11_FEATURES
if #available(macOS 11.0, *) {
switch outputCsp {