gpui/platform/color_presentation.rs
1//! Window presentation intent, independent of native UI color types.
2
3/// Presentation intent for one window. Existing UI colors retain sRGB meaning.
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum WindowColorMode {
7 /// Preserve the platform's existing presentation behavior.
8 #[default]
9 Default,
10 /// Compose SDR wide-gamut content with ordinary sRGB controls.
11 WideGamutSdr,
12}
13
14/// Why negotiated output differs from the requested presentation class.
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16#[non_exhaustive]
17pub enum WindowColorFallback {
18 /// The host explicitly maps wide content to an SDR display's sRGB output.
19 SdrDisplay,
20 /// Another platform policy restricts presentation.
21 PlatformPolicy,
22}
23
24/// An immutable snapshot of one window's negotiated presentation configuration.
25/// Effective mode describes the next-frame configuration, not monitor delivery.
26#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
27pub struct WindowColorStatus {
28 requested: WindowColorMode,
29 effective: WindowColorMode,
30 supports_wide_gamut_sdr: bool,
31 display_wide_gamut: Option<bool>,
32 fallback: Option<WindowColorFallback>,
33}
34impl WindowColorStatus {
35 /// Construct a backend report. This does not change a window's configuration.
36 pub fn new(
37 requested: WindowColorMode,
38 effective: WindowColorMode,
39 supports_wide_gamut_sdr: bool,
40 display_wide_gamut: Option<bool>,
41 fallback: Option<WindowColorFallback>,
42 ) -> Self {
43 Self {
44 requested,
45 effective,
46 supports_wide_gamut_sdr,
47 display_wide_gamut,
48 fallback,
49 }
50 }
51 /// The most recently accepted request.
52 pub fn requested(&self) -> WindowColorMode {
53 self.requested
54 }
55 /// The negotiated output class; independent of internal working textures.
56 pub fn effective(&self) -> WindowColorMode {
57 self.effective
58 }
59 /// Whether this backend can negotiate wide-gamut SDR presentation.
60 pub fn supports_wide_gamut_sdr(&self) -> bool {
61 self.supports_wide_gamut_sdr
62 }
63 /// OS display-profile evidence; `None` means unknown, not unsupported.
64 pub fn display_wide_gamut(&self) -> Option<bool> {
65 self.display_wide_gamut
66 }
67 /// The reason for an active output fallback, if any.
68 pub fn fallback(&self) -> Option<WindowColorFallback> {
69 self.fallback
70 }
71}