show the oklab color space

This commit is contained in:
nora 2025-12-28 18:27:27 +01:00
parent 47cc8616f0
commit 6a8eabf9f2
3 changed files with 45 additions and 3 deletions

23
Cargo.lock generated
View file

@ -204,6 +204,12 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "fast-srgb8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"
[[package]] [[package]]
name = "find-msvc-tools" name = "find-msvc-tools"
version = "0.1.6" version = "0.1.6"
@ -285,6 +291,16 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "oklab"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e35ab3c8efa6bc97d651abe7fb051aebb30c925a450ff6722cf9c797a938cc"
dependencies = [
"fast-srgb8",
"rgb",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.21.3" version = "1.21.3"
@ -394,6 +410,12 @@ version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
[[package]]
name = "rgb"
version = "0.8.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "1.1.3" version = "1.1.3"
@ -542,6 +564,7 @@ dependencies = [
"env_logger", "env_logger",
"eyre", "eyre",
"log", "log",
"oklab",
"smithay-client-toolkit", "smithay-client-toolkit",
"wayland-client", "wayland-client",
] ]

View file

@ -7,5 +7,6 @@ edition = "2024"
env_logger = "0.11.8" env_logger = "0.11.8"
eyre = "0.6.12" eyre = "0.6.12"
log = "0.4.29" log = "0.4.29"
oklab = "1.1.2"
smithay-client-toolkit = "0.20.0" smithay-client-toolkit = "0.20.0"
wayland-client = "0.31.11" wayland-client = "0.31.11"

View file

@ -130,6 +130,15 @@ impl OutputHandler for App {
_qh: &QueueHandle<Self>, _qh: &QueueHandle<Self>,
output: wayland_client::protocol::wl_output::WlOutput, output: wayland_client::protocol::wl_output::WlOutput,
) { ) {
match self.output_state.info(&output) {
None => warn!("Output disconnected, unknown information"),
Some(info) => {
info!(
"Output disconnected ({})",
info.description.unwrap_or_else(|| "<unknown>".into()),
);
}
}
if let Some(suface_idx) = self if let Some(suface_idx) = self
.layer_surfaces .layer_surfaces
.iter() .iter()
@ -215,10 +224,19 @@ impl LayerShellHandler for App {
let x = (index % width as usize) as u32; let x = (index % width as usize) as u32;
let y = (index / width as usize) as u32; let y = (index / width as usize) as u32;
let xf = x as f32 / width as f32;
let yf = y as f32 / height as f32;
let srgb = oklab::oklab_to_srgb(oklab::Oklab {
l: 0.7,
a: xf * 0.8 - 0.4,
b: yf * 0.8 - 0.4,
});
let a = 0xFF; let a = 0xFF;
let r = u32::min(((width - x) * 0xFF) / width, ((height - y) * 0xFF) / height); let r = srgb.r as u32;
let g = u32::min((x * 0xFF) / width, ((height - y) * 0xFF) / height); let g = srgb.g as u32;
let b = u32::min(((width - x) * 0xFF) / width, (y * 0xFF) / height); let b = srgb.b as u32;
let color = (a << 24) + (r << 16) + (g << 8) + b; let color = (a << 24) + (r << 16) + (g << 8) + b;
let array: &mut [u8; 4] = chunk.try_into().unwrap(); let array: &mut [u8; 4] = chunk.try_into().unwrap();