@@ -14,6 +14,7 @@ use crate::{FloatComponent, Xyz};
14
14
pub type Mat3 < T > = [ T ; 9 ] ;
15
15
16
16
/// Multiply the 3x3 matrix with an XYZ color.
17
+ #[ inline]
17
18
pub fn multiply_xyz < Swp : WhitePoint , Dwp : WhitePoint , T : FloatComponent > (
18
19
c : & Mat3 < T > ,
19
20
f : & Xyz < Swp , T > ,
@@ -39,6 +40,7 @@ pub fn multiply_xyz<Swp: WhitePoint, Dwp: WhitePoint, T: FloatComponent>(
39
40
}
40
41
}
41
42
/// Multiply the 3x3 matrix with an XYZ color to return an RGB color.
43
+ #[ inline]
42
44
pub fn multiply_xyz_to_rgb < S : RgbSpace , T : FloatComponent > (
43
45
c : & Mat3 < T > ,
44
46
f : & Xyz < S :: WhitePoint , T > ,
@@ -55,6 +57,7 @@ pub fn multiply_xyz_to_rgb<S: RgbSpace, T: FloatComponent>(
55
57
}
56
58
}
57
59
/// Multiply the 3x3 matrix with an RGB color to return an XYZ color.
60
+ #[ inline]
58
61
pub fn multiply_rgb_to_xyz < S : RgbSpace , T : FloatComponent > (
59
62
c : & Mat3 < T > ,
60
63
f : & Rgb < Linear < S > , T > ,
@@ -72,6 +75,7 @@ pub fn multiply_rgb_to_xyz<S: RgbSpace, T: FloatComponent>(
72
75
}
73
76
74
77
/// Multiply two 3x3 matrices.
78
+ #[ inline]
75
79
pub fn multiply_3x3 < T : Float > ( c : & Mat3 < T > , f : & Mat3 < T > ) -> Mat3 < T > {
76
80
// Input Mat3 are destructured to avoid panic paths
77
81
let [ c0, c1, c2, c3, c4, c5, c6, c7, c8] = * c;
@@ -93,6 +97,7 @@ pub fn multiply_3x3<T: Float>(c: &Mat3<T>, f: &Mat3<T>) -> Mat3<T> {
93
97
}
94
98
95
99
/// Invert a 3x3 matrix and panic if matrix is not invertible.
100
+ #[ inline]
96
101
pub fn matrix_inverse < T : Float > ( a : & Mat3 < T > ) -> Mat3 < T > {
97
102
// This function runs fastest with assert and no destructuring. The `det`'s
98
103
// location should not be changed until benched that it's faster elsewhere
@@ -128,6 +133,7 @@ pub fn matrix_inverse<T: Float>(a: &Mat3<T>) -> Mat3<T> {
128
133
}
129
134
130
135
/// Generates the Srgb to Xyz transformation matrix for a given white point.
136
+ #[ inline]
131
137
pub fn rgb_to_xyz_matrix < S : RgbSpace , T : FloatComponent > ( ) -> Mat3 < T > {
132
138
let r: Xyz < S :: WhitePoint , T > = S :: Primaries :: red ( ) . into_color_unclamped ( ) ;
133
139
let g: Xyz < S :: WhitePoint , T > = S :: Primaries :: green ( ) . into_color_unclamped ( ) ;
@@ -155,6 +161,7 @@ pub fn rgb_to_xyz_matrix<S: RgbSpace, T: FloatComponent>() -> Mat3<T> {
155
161
}
156
162
157
163
#[ rustfmt:: skip]
164
+ #[ inline]
158
165
fn mat3_from_primaries < T : FloatComponent , Wp : WhitePoint > ( r : Xyz < Wp , T > , g : Xyz < Wp , T > , b : Xyz < Wp , T > ) -> Mat3 < T > {
159
166
[
160
167
r. x , g. x , b. x ,
0 commit comments