diff --git a/src-tauri/src/platform/macos.rs b/src-tauri/src/platform/macos.rs index d9334f6..4bb331f 100644 --- a/src-tauri/src/platform/macos.rs +++ b/src-tauri/src/platform/macos.rs @@ -14,8 +14,8 @@ use std::sync::Arc; use objc2::rc::Retained; use objc2::{define_class, msg_send, AllocAnyThread, DefinedClass, MainThreadMarker}; use objc2_app_kit::{NSAutoresizingMaskOptions, NSView, NSWindow, NSWindowButton, NSWindowOrderingMode}; -use objc2_core_foundation::CFTimeInterval; -use objc2_core_graphics::{kCGColorSpaceITUR_2100_PQ, CGColorSpace}; +use objc2_core_foundation::{CFRetained, CFTimeInterval}; +use objc2_core_graphics::{kCGColorSpaceITUR_2100_PQ, kCGColorSpaceSRGB, CGColorSpace}; use objc2_core_video::CVTimeStamp; use objc2_foundation::{NSNumber, NSPoint, NSRect, NSSize, NSString}; use objc2_open_gl::*; @@ -131,6 +131,10 @@ extern "C" fn on_update(wake: *mut c_void) { let _ = wake.try_send(()); } +fn srgb() -> Option> { + CGColorSpace::with_name(Some(unsafe { kCGColorSpaceSRGB })) +} + // —— The video layer ——————————————————————————————————————————————————— struct LayerIvars { @@ -211,6 +215,9 @@ impl VideoLayer { let this = VideoLayer::alloc().set_ivars(LayerIvars { cgl, pixel_format, float, render: Mutex::new(None) }); let layer: Retained = unsafe { msg_send![super(this), init] }; layer.setAsynchronous(false); + // A float framebuffer without a colour space would be read as linear + // light, washing SDR out; mpv writes gamma-encoded SDR, as for Windows. + layer.setColorspace(srgb().as_deref()); layer.setNeedsDisplayOnBoundsChange(true); layer.setOpaque(true); layer @@ -393,7 +400,7 @@ impl VideoSurface { /// HDR passthrough: for PQ or HLG video, mpv outputs PQ (BT.2020) instead of /// tone-mapping to SDR, and the layer shows it in extended dynamic range, so - /// macOS maps it to the display's HDR headroom. SDR video uses the defaults. + /// macOS maps it to the display's HDR headroom. SDR video is shown as sRGB. pub fn on_property(&mut self, name: &str, value: &serde_json::Value) { if name != "video-params/gamma" { return; @@ -413,8 +420,8 @@ impl VideoSurface { let layer = &self.ui.layer; CATransaction::begin(); layer.setWantsExtendedDynamicRangeContent(edr); - let pq = if edr { CGColorSpace::with_name(Some(unsafe { kCGColorSpaceITUR_2100_PQ })) } else { None }; - layer.setColorspace(pq.as_deref()); + let space = if edr { CGColorSpace::with_name(Some(unsafe { kCGColorSpaceITUR_2100_PQ })) } else { srgb() }; + layer.setColorspace(space.as_deref()); CATransaction::commit(); } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1646121..5494755 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -31,9 +31,12 @@ "csp": null, "assetProtocol": { "enable": true, - "scope": [ - "**" - ] + "scope": { + "allow": [ + "**" + ], + "requireLiteralLeadingDot": false + } } } },