diff --git a/palette/src/matrix.rs b/palette/src/matrix.rs index da3211915..a68b1e3c7 100644 --- a/palette/src/matrix.rs +++ b/palette/src/matrix.rs @@ -14,6 +14,7 @@ use crate::{FloatComponent, Xyz}; pub type Mat3 = [T; 9]; /// Multiply the 3x3 matrix with an XYZ color. +#[inline] pub fn multiply_xyz( c: &Mat3, f: &Xyz, @@ -39,6 +40,7 @@ pub fn multiply_xyz( } } /// Multiply the 3x3 matrix with an XYZ color to return an RGB color. +#[inline] pub fn multiply_xyz_to_rgb( c: &Mat3, f: &Xyz, @@ -55,6 +57,7 @@ pub fn multiply_xyz_to_rgb( } } /// Multiply the 3x3 matrix with an RGB color to return an XYZ color. +#[inline] pub fn multiply_rgb_to_xyz( c: &Mat3, f: &Rgb, T>, @@ -72,6 +75,7 @@ pub fn multiply_rgb_to_xyz( } /// Multiply two 3x3 matrices. +#[inline] pub fn multiply_3x3(c: &Mat3, f: &Mat3) -> Mat3 { // Input Mat3 are destructured to avoid panic paths let [c0, c1, c2, c3, c4, c5, c6, c7, c8] = *c; @@ -93,6 +97,7 @@ pub fn multiply_3x3(c: &Mat3, f: &Mat3) -> Mat3 { } /// Invert a 3x3 matrix and panic if matrix is not invertible. +#[inline] pub fn matrix_inverse(a: &Mat3) -> Mat3 { // This function runs fastest with assert and no destructuring. The `det`'s // location should not be changed until benched that it's faster elsewhere @@ -128,6 +133,7 @@ pub fn matrix_inverse(a: &Mat3) -> Mat3 { } /// Generates the Srgb to Xyz transformation matrix for a given white point. +#[inline] pub fn rgb_to_xyz_matrix() -> Mat3 { let r: Xyz = S::Primaries::red().into_color_unclamped(); let g: Xyz = S::Primaries::green().into_color_unclamped(); @@ -155,6 +161,7 @@ pub fn rgb_to_xyz_matrix() -> Mat3 { } #[rustfmt::skip] +#[inline] fn mat3_from_primaries(r: Xyz, g: Xyz, b: Xyz) -> Mat3 { [ r.x, g.x, b.x,