use crate::ifs::color_management::ABSOLUTE_NO_ADAPTATION_SINCE;
use crate::ifs::color_management::RENDER_INTENT_ABSOLUTE_NO_ADAPTATION;
use crate::ifs::color_management::RENDER_INTENT_PERCEPTUAL;
use crate::ifs::color_management::RENDER_INTENT_RELATIVE;
use crate::ifs::color_management::RENDER_INTENT_RELATIVE_BPC;
use crate::object::Version;
use crate::utils::static_text::StaticText;
use jay_proc::jay_hash;
#[jay_hash]
#[derive(Copy, Clone, Debug, Eq, Default)]
pub enum RenderIntent {
#[default]
Perceptual,
Relative,
RelativeBpc,
AbsoluteNoAdaptation,
}
impl StaticText for RenderIntent {
fn text(&self) -> &'static str {
match self {
RenderIntent::Perceptual => "perceptual",
RenderIntent::Relative => "relative",
RenderIntent::RelativeBpc => "relative_bpc",
RenderIntent::AbsoluteNoAdaptation => "absolute_no_adaptation",
}
}
}
impl RenderIntent {
pub fn from_wayland(intent: u32, version: Version) -> Option<Self> {
let res = match intent {
RENDER_INTENT_PERCEPTUAL => Self::Perceptual,
RENDER_INTENT_RELATIVE => Self::Relative,
RENDER_INTENT_RELATIVE_BPC => Self::RelativeBpc,
RENDER_INTENT_ABSOLUTE_NO_ADAPTATION if version >= ABSOLUTE_NO_ADAPTATION_SINCE => {
Self::AbsoluteNoAdaptation
}
_ => return None,
};
Some(res)
}
pub fn black_point_compensation(self) -> bool {
match self {
RenderIntent::Perceptual => true,
RenderIntent::RelativeBpc => true,
RenderIntent::Relative => false,
RenderIntent::AbsoluteNoAdaptation => false,
}
}
pub fn bradford_adjustment(self) -> bool {
match self {
RenderIntent::Perceptual => true,
RenderIntent::RelativeBpc => true,
RenderIntent::Relative => true,
RenderIntent::AbsoluteNoAdaptation => false,
}
}
}