color: non-sRGB preview, per-monitor display ICC, pipeline hardening

Preview now follows the project output colorspace end to end: the
display chain derives its content space from the project's OutputColorSpec
instead of a hardcoded sRGB name, self-managed ICC transforms go through
an XYZ D65 interchange stage (OCIO cie_xyz_d65_interchange) for non-sRGB
targets, and the platform layer declares the content colorspace (gpui
submodule bump). macOS defaults to OS-managed (fixes wide-gamut UI
oversaturation); Windows ACM warns once on non-sRGB targets.

Multi-monitor: the display ICC is looked up per the window's current
screen (macOS display id, Windows per-monitor DC, X11 RandR output
profile) with a throttled poll that invalidates frame caches on moves.

Pipeline precision: 10-bit+ sources fall back to YUV444P16LE + a Rust
matrix conversion when swscale lacks F32 output (no more 8-bit
truncation); BT.709/2020 SDR decodes with BT.1886 gamma 2.4 instead of
the sRGB EOTF; working-space compositing no longer clamps RGB to [0,1]
(alpha still clamped); the output node clamps to the target gamut;
frames without colorimetry metadata convert with BT.709 defaults
(warned once) instead of passing through; scopes read the
output-colorspace signal on both F32 paths.

Also: only emit rerun-if-changed for .env when it exists (a missing file
made every build fully dirty).
This commit is contained in:
2026-08-29 00:24:15 +08:00
parent 879ff8da5b
commit fdb5caabd5
42 changed files with 4423 additions and 146 deletions
+40
View File
@@ -83,6 +83,15 @@ pub const SETTING_ROOT: &str = "root";
pub const SETTING_CACHE_LOCATION: &str = "cachesetting";
/// Setting key for the custom cache path (C++ `k_cache_path_key`).
pub const SETTING_CACHE_PATH: &str = "customcachepath";
/// Setting key: the pipeline working colorspace ("acescg" | "srgb_legacy").
/// Absent = the default (ACEScg).
pub const SETTING_WORKING_COLOR_SPACE: &str = "workingcolorspace";
/// Setting key: the output/delivery gamut ("srgb" | "displayp3" | "bt2020").
/// Absent = sRGB.
pub const SETTING_OUTPUT_GAMUT: &str = "outputgamut";
/// Setting key: the output/delivery transfer ("srgb" | "gamma22" | "pq" |
/// "hlg"). Absent = sRGB.
pub const SETTING_OUTPUT_TRANSFER: &str = "outputtransfer";
impl Project {
/// New empty project (no root folder until [`Project::initialize`]).
@@ -129,6 +138,37 @@ impl Project {
Ok(())
}
/// The pipeline working colorspace (project property; ACEScg when the
/// setting is absent).
pub fn working_color_space(&self) -> oak_common::colormath::WorkingColorSpace {
oak_common::colormath::WorkingColorSpace::from_setting(
self.settings.get(SETTING_WORKING_COLOR_SPACE).map(String::as_str).unwrap_or(""),
)
}
/// The output/delivery colorspace (project property; sRGB when the
/// settings are absent).
pub fn output_color_spec(&self) -> oak_common::colormath::OutputColorSpec {
oak_common::colormath::OutputColorSpec::from_settings(
self.settings.get(SETTING_OUTPUT_GAMUT).map(String::as_str).unwrap_or(""),
self.settings.get(SETTING_OUTPUT_TRANSFER).map(String::as_str).unwrap_or(""),
)
}
/// Set the pipeline working colorspace property.
pub fn set_working_color_space(&mut self, space: oak_common::colormath::WorkingColorSpace) {
self.settings
.insert(SETTING_WORKING_COLOR_SPACE.to_string(), space.as_setting().to_string());
}
/// Set the output/delivery colorspace properties.
pub fn set_output_color_spec(&mut self, spec: oak_common::colormath::OutputColorSpec) {
self.settings
.insert(SETTING_OUTPUT_GAMUT.to_string(), spec.gamut.as_setting().to_string());
self.settings
.insert(SETTING_OUTPUT_TRANSFER.to_string(), spec.transfer.as_setting().to_string());
}
/// Deep-copy the whole project for background render isolation
/// (replaces oakrender's C++ ProjectCopier: the copy happens here,
/// inside the module that owns the data — see M-series note on