1
0
Fork 0
forked from wry/wry

color-management: use more consistent naming

This commit is contained in:
Julian Orth 2025-09-05 13:45:09 +02:00
parent 32db933242
commit 83e79b68e6
65 changed files with 439 additions and 510 deletions

View file

@ -1,7 +1,7 @@
use {
crate::{
cli::{GlobalArgs, color::parse_color, duration::parse_duration},
cmm::cmm_transfer_function::TransferFunction,
cmm::cmm_eotf::Eotf,
tools::tool_client::{ToolClient, with_tool_client},
wire::jay_damage_tracking::{SetVisualizerColor, SetVisualizerDecay, SetVisualizerEnabled},
},
@ -86,7 +86,7 @@ impl DamageTracking {
}
DamageTrackingCmd::SetColor(c) => {
let color = parse_color(&c.color);
let [r, g, b, a] = color.to_array(TransferFunction::Gamma22);
let [r, g, b, a] = color.to_array(Eotf::Gamma22);
tc.send(SetVisualizerColor {
self_id: dt,
r,

View file

@ -1,6 +1,6 @@
use {
crate::{
backend::{BackendColorSpace, BackendTransferFunction},
backend::{BackendColorSpace, BackendEotfs},
cli::GlobalArgs,
format::{Format, XRGB8888},
scale::Scale,
@ -333,14 +333,14 @@ pub struct ColorsSettings {
#[derive(Subcommand, Debug, Clone)]
pub enum ColorsCommand {
/// Sets the color space and transfer function of the output.
/// Sets the color space and EOTF of the output.
Set {
/// The name of the color space.
#[clap(value_parser = PossibleValuesParser::new(color_space_possible_values()))]
color_space: String,
/// The name of the transfer function.
#[clap(value_parser = PossibleValuesParser::new(transfer_function_possible_values()))]
transfer_function: String,
/// The name of the EOTF.
#[clap(value_parser = PossibleValuesParser::new(eotf_possible_values()))]
eotf: String,
},
}
@ -357,13 +357,13 @@ fn color_space_possible_values() -> Vec<PossibleValue> {
res
}
fn transfer_function_possible_values() -> Vec<PossibleValue> {
fn eotf_possible_values() -> Vec<PossibleValue> {
let mut res = vec![];
for cs in BackendTransferFunction::variants() {
use BackendTransferFunction::*;
for cs in BackendEotfs::variants() {
use BackendEotfs::*;
let help = match cs {
Default => "The default transfer function (usually sRGB)",
Pq => "The PQ transfer function",
Default => "The default EOTF (usually gamma22)",
Pq => "The PQ EOTF",
};
res.push(PossibleValue::new(cs.name()).help(help));
}
@ -375,12 +375,12 @@ pub struct BrightnessArgs {
/// The brightness of standard white in cd/m^2 or `default` to use the default
/// brightness.
///
/// The default brightness depends on the transfer function:
/// The default brightness depends on the EOTF:
///
/// - default: the maximum display brightness
/// - PQ: 203 cd/m^2.
///
/// When using the default transfer function, you likely want to set this to `default`
/// When using the default EOTF, you likely want to set this to `default`
/// and adjust the display hardware brightness setting instead.
///
/// This has no effect unless the vulkan renderer is used.
@ -462,8 +462,8 @@ struct Output {
pub flip_margin_ns: Option<u64>,
pub supported_color_spaces: Vec<String>,
pub current_color_space: Option<String>,
pub supported_transfer_functions: Vec<String>,
pub current_transfer_function: Option<String>,
pub supported_eotfs: Vec<String>,
pub current_eotf: Option<String>,
pub brightness_range: Option<(f64, f64)>,
pub brightness: Option<f64>,
}
@ -713,15 +713,12 @@ impl Randr {
eprintln!("Could not change the colors: {}", msg);
});
match a.command {
ColorsCommand::Set {
color_space,
transfer_function,
} => {
ColorsCommand::Set { color_space, eotf } => {
tc.send(jay_randr::SetColors {
self_id: randr,
output: &args.output,
color_space: &color_space,
transfer_function: &transfer_function,
eotf: &eotf,
});
}
}
@ -957,19 +954,17 @@ impl Randr {
handle_cs("default");
o.supported_color_spaces.iter().for_each(|cs| handle_cs(cs));
}
if o.supported_transfer_functions.is_not_empty() {
println!(" transfer functions:");
if o.supported_eotfs.is_not_empty() {
println!(" eotfs:");
let handle_tf = |tf: &str| {
let current = match Some(tf) == o.current_transfer_function.as_deref() {
let current = match Some(tf) == o.current_eotf.as_deref() {
false => "",
true => " (current)",
};
println!(" {tf}{current}");
};
handle_tf("default");
o.supported_transfer_functions
.iter()
.for_each(|tf| handle_tf(tf));
o.supported_eotfs.iter().for_each(|tf| handle_tf(tf));
}
if let Some((min, max)) = o.brightness_range {
println!(" min brightness: {:>10.4} cd/m^2", min);
@ -1130,19 +1125,17 @@ impl Randr {
let output = c.output.as_mut().unwrap();
output.current_color_space = Some(msg.color_space.to_string());
});
jay_randr::SupportedTransferFunction::handle(tc, randr, data.clone(), |data, msg| {
jay_randr::SupportedEotf::handle(tc, randr, data.clone(), |data, msg| {
let mut data = data.borrow_mut();
let c = data.connectors.last_mut().unwrap();
let output = c.output.as_mut().unwrap();
output
.supported_transfer_functions
.push(msg.transfer_function.to_string());
output.supported_eotfs.push(msg.eotf.to_string());
});
jay_randr::CurrentTransferFunction::handle(tc, randr, data.clone(), |data, msg| {
jay_randr::CurrentEotf::handle(tc, randr, data.clone(), |data, msg| {
let mut data = data.borrow_mut();
let c = data.connectors.last_mut().unwrap();
let output = c.output.as_mut().unwrap();
output.current_transfer_function = Some(msg.transfer_function.to_string());
output.current_eotf = Some(msg.eotf.to_string());
});
jay_randr::BrightnessRange::handle(tc, randr, data.clone(), |data, msg| {
let mut data = data.borrow_mut();