palette/encoding/
linear.rs1use core::marker::PhantomData;
4
5use crate::{
6 luma::LumaStandard,
7 rgb::{RgbSpace, RgbStandard},
8};
9
10use super::{FromLinear, IntoLinear};
11
12#[derive(Copy, Clone, Debug, PartialEq, Eq)]
14pub struct Linear<S>(PhantomData<S>);
15
16impl<Sp> RgbStandard for Linear<Sp>
17where
18 Sp: RgbSpace,
19{
20 type Space = Sp;
21 type TransferFn = LinearFn;
22}
23
24impl<Wp> LumaStandard for Linear<Wp> {
25 type WhitePoint = Wp;
26 type TransferFn = LinearFn;
27}
28
29#[derive(Copy, Clone, Debug, PartialEq, Eq)]
35pub struct LinearFn;
36
37impl<T> IntoLinear<T, T> for LinearFn {
38 #[inline(always)]
39 fn into_linear(x: T) -> T {
40 x
41 }
42}
43
44impl<T> FromLinear<T, T> for LinearFn {
45 #[inline(always)]
46 fn from_linear(x: T) -> T {
47 x
48 }
49}