diff --git a/Cargo.lock b/Cargo.lock index 573a521412..1ac11475f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3144,9 +3144,6 @@ name = "craft-texture" version = "0.1.0" dependencies = [ "bytemuck", - "craft-cms", - "craft-mesh", - "craft-psd", "dds", "half", "rayon", diff --git a/crates/texture/Cargo.toml b/crates/texture/Cargo.toml index 427a92c64e..964fafa41a 100644 --- a/crates/texture/Cargo.toml +++ b/crates/texture/Cargo.toml @@ -24,9 +24,6 @@ dds = { version = "0.2.0", default-features = false, optional = true } bytemuck = { workspace = true, optional = true } [dev-dependencies] -craft-cms = { workspace = true } -craft-mesh = { workspace = true } -craft-psd = { workspace = true } half = "2" dds = { version = "0.2.0", default-features = false } bytemuck = { workspace = true } diff --git a/crates/texture/tests/it/main.rs b/crates/texture/tests/it/main.rs new file mode 100644 index 0000000000..c798d9d248 --- /dev/null +++ b/crates/texture/tests/it/main.rs @@ -0,0 +1,3 @@ +//! The crate's integration tests, linked into one test binary. + +mod srgb; diff --git a/crates/texture/tests/srgb.rs b/crates/texture/tests/it/srgb.rs similarity index 73% rename from crates/texture/tests/srgb.rs rename to crates/texture/tests/it/srgb.rs index 4edd74086a..3ccf5f4f3c 100644 --- a/crates/texture/tests/srgb.rs +++ b/crates/texture/tests/it/srgb.rs @@ -1,5 +1,4 @@ -//! The scalar sRGB pair against IEC 61966-2-1 and against the copies of it in craft-cms, -//! craft-mesh and craft-psd. +//! The scalar sRGB pair against IEC 61966-2-1. //! //! The encoding is the one the ICC sRGB registry entry gives for IEC 61966-2-1:1999 //! (); the decoding is the CSS Color 4 sample code @@ -11,15 +10,9 @@ use craft_texture::{linear_to_srgb, srgb_to_linear}; /// The largest difference allowed between the `f32` pair and the `f64` formulas. const STANDARD_TOLERANCE: f32 = 3.0e-7; -/// The largest difference allowed between the pair and craft-cms's ICC curve, which is evaluated -/// in `f64` and returned as `f32`. -const CMS_TOLERANCE: f32 = 2.4e-7; /// The 8-bit and 16-bit code ranges. const DEPTHS: [u32; 2] = [255, 65_535]; -/// One direction of an sRGB pair. -type Scalar = fn(f32) -> f32; - fn encode64(c: f64) -> f64 { if c <= 0.003_130_8 { c * 12.92 } else { 1.055 * c.powf(1.0 / 2.4) - 0.055 } } @@ -53,9 +46,6 @@ fn worst_fails_on_a_difference_that_is_not_finite() { worst(255, |_| f32::NAN, |v| v); } -/// Inputs outside `[0, 1]` that the crates' copies must also agree on. -const OUTSIDE: [f32; 10] = [-0.0, -1.0e-6, -0.5, -1.0, -100.0, 1.5, 2.0, 100.0, f32::INFINITY, f32::NEG_INFINITY]; - #[test] fn encode_matches_the_standard_at_every_8_and_16_bit_code() { for max in DEPTHS { @@ -165,43 +155,3 @@ fn infinities_keep_their_sign_and_nan_stays_nan() { assert!(f(f32::NAN).is_nan()); } } - -#[test] -fn mesh_pair_matches_bit_for_bit() { - let pairs: [(Scalar, Scalar); 2] = [(linear_to_srgb, craft_mesh::linear_to_srgb), (srgb_to_linear, craft_mesh::srgb_to_linear)]; - for (ours, mesh) in pairs { - for max in DEPTHS { - for (n, v) in codes(max) { - assert_eq!(ours(v).to_bits(), mesh(v).to_bits(), "code {n} of {max}"); - } - } - for v in OUTSIDE { - assert_eq!(ours(v).to_bits(), mesh(v).to_bits(), "{v}"); - } - assert!(mesh(f32::NAN).is_nan()); - } -} - -#[test] -fn psd_encoder_matches_bit_for_bit() { - for max in DEPTHS { - for (n, v) in codes(max) { - assert_eq!(linear_to_srgb(v).to_bits(), craft_psd::float::srgb_encode(v).to_bits(), "code {n} of {max}"); - } - } - for v in OUTSIDE { - assert_eq!(linear_to_srgb(v).to_bits(), craft_psd::float::srgb_encode(v).to_bits(), "{v}"); - } - assert!(craft_psd::float::srgb_encode(f32::NAN).is_nan()); -} - -#[test] -fn cms_curve_matches_within_rounding() { - let trc = craft_cms::curve::srgb_trc(); - for max in DEPTHS { - let (d, n) = worst(max, srgb_to_linear, |v| trc.eval(v)); - assert!(d <= CMS_TOLERANCE, "decode code {n} of {max} is {d} from craft-cms"); - let (d, n) = worst(max, linear_to_srgb, |v| trc.eval_inverse(v)); - assert!(d <= CMS_TOLERANCE, "encode code {n} of {max} is {d} from craft-cms"); - } -}