Skip to content

Commit 07ac642

Browse files
committed
Add inline to matrix functions
1 parent fb1798e commit 07ac642

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

palette/src/matrix.rs

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{FloatComponent, Xyz};
1414
pub type Mat3<T> = [T; 9];
1515

1616
/// Multiply the 3x3 matrix with an XYZ color.
17+
#[inline]
1718
pub fn multiply_xyz<Swp: WhitePoint, Dwp: WhitePoint, T: FloatComponent>(
1819
c: &Mat3<T>,
1920
f: &Xyz<Swp, T>,
@@ -39,6 +40,7 @@ pub fn multiply_xyz<Swp: WhitePoint, Dwp: WhitePoint, T: FloatComponent>(
3940
}
4041
}
4142
/// Multiply the 3x3 matrix with an XYZ color to return an RGB color.
43+
#[inline]
4244
pub fn multiply_xyz_to_rgb<S: RgbSpace, T: FloatComponent>(
4345
c: &Mat3<T>,
4446
f: &Xyz<S::WhitePoint, T>,
@@ -55,6 +57,7 @@ pub fn multiply_xyz_to_rgb<S: RgbSpace, T: FloatComponent>(
5557
}
5658
}
5759
/// Multiply the 3x3 matrix with an RGB color to return an XYZ color.
60+
#[inline]
5861
pub fn multiply_rgb_to_xyz<S: RgbSpace, T: FloatComponent>(
5962
c: &Mat3<T>,
6063
f: &Rgb<Linear<S>, T>,
@@ -72,6 +75,7 @@ pub fn multiply_rgb_to_xyz<S: RgbSpace, T: FloatComponent>(
7275
}
7376

7477
/// Multiply two 3x3 matrices.
78+
#[inline]
7579
pub fn multiply_3x3<T: Float>(c: &Mat3<T>, f: &Mat3<T>) -> Mat3<T> {
7680
// Input Mat3 are destructured to avoid panic paths
7781
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> {
9397
}
9498

9599
/// Invert a 3x3 matrix and panic if matrix is not invertible.
100+
#[inline]
96101
pub fn matrix_inverse<T: Float>(a: &Mat3<T>) -> Mat3<T> {
97102
// This function runs fastest with assert and no destructuring. The `det`'s
98103
// 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> {
128133
}
129134

130135
/// Generates the Srgb to Xyz transformation matrix for a given white point.
136+
#[inline]
131137
pub fn rgb_to_xyz_matrix<S: RgbSpace, T: FloatComponent>() -> Mat3<T> {
132138
let r: Xyz<S::WhitePoint, T> = S::Primaries::red().into_color_unclamped();
133139
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> {
155161
}
156162

157163
#[rustfmt::skip]
164+
#[inline]
158165
fn mat3_from_primaries<T: FloatComponent, Wp: WhitePoint>(r: Xyz<Wp, T>, g: Xyz<Wp, T>, b: Xyz<Wp, T>) -> Mat3<T> {
159166
[
160167
r.x, g.x, b.x,

0 commit comments

Comments
 (0)