drmkit_display/color.rs
1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! Color primaries, independent of where they came from.
5//!
6//! These describe a set of primaries and a white point. An EDID is one source
7//! of them and HDR source metadata is another, so they live apart from the
8//! parser -- a caller describing the content it is emitting should not have to
9//! build the crate against `libdisplay-info` to name a primary.
10
11/// A CIE 1931 chromaticity coordinate.
12#[derive(Debug, Clone, Copy, PartialEq, Default)]
13#[allow(
14 clippy::exhaustive_structs,
15 reason = "a value defined by its fields; there is nothing to add to it"
16)]
17pub struct Chromaticity {
18 /// x coordinate.
19 pub x: f32,
20 /// y coordinate.
21 pub y: f32,
22}
23
24/// The display's color primaries and white point.
25#[derive(Debug, Clone, Copy, PartialEq, Default)]
26#[allow(
27 clippy::exhaustive_structs,
28 reason = "built by callers with `..Default::default()`, which a new field does not break"
29)]
30pub struct ColorimetryInfo {
31 /// Red primary.
32 pub red: Chromaticity,
33 /// Green primary.
34 pub green: Chromaticity,
35 /// Blue primary.
36 pub blue: Chromaticity,
37 /// Default white point.
38 pub white: Chromaticity,
39 /// Whether the primaries are present. When false the three above are
40 /// meaningless rather than zero-valued.
41 pub has_primaries: bool,
42 /// Whether the white point is present.
43 pub has_default_white: bool,
44}