Fix washed-out SDR video and missing download artwork on macOS
The video layer's float framebuffer had no colour space, so macOS read gamma-encoded SDR as linear light; SDR is now tagged sRGB (HDR keeps BT.2100 PQ). Downloaded artwork is kept in dot-files, which the asset protocol's "**" scope skips on macOS unless leading dots are allowed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3aacb94048
commit
a7aad59409
2 changed files with 18 additions and 8 deletions
|
|
@ -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<CFRetained<CGColorSpace>> {
|
||||
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<VideoLayer> = 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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,12 @@
|
|||
"csp": null,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": [
|
||||
"**"
|
||||
]
|
||||
"scope": {
|
||||
"allow": [
|
||||
"**"
|
||||
],
|
||||
"requireLiteralLeadingDot": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue