tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

lib.rs (2101B)


      1 /*! A pure Rust color management library.
      2 */
      3 
      4 #![allow(dead_code)]
      5 #![allow(non_camel_case_types)]
      6 #![allow(non_snake_case)]
      7 #![allow(non_upper_case_globals)]
      8 // These are needed for the neon SIMD code and can be removed once the MSRV supports the
      9 // instrinsics we use
     10 #![cfg_attr(all(target_arch = "arm", feature = "neon"), feature(stdarch_arm_neon_intrinsics))]
     11 #![cfg_attr(all(target_arch = "arm", feature = "neon"), feature(stdarch_arm_feature_detection))]
     12 #![cfg_attr(
     13    all(target_arch = "arm", feature = "neon"),
     14    feature(arm_target_feature)
     15 )]
     16 
     17 /// These values match the Rendering Intent values from the ICC spec
     18 #[repr(C)]
     19 #[derive(Clone, Copy, Debug)]
     20 pub enum Intent {
     21    AbsoluteColorimetric = 3,
     22    Saturation = 2,
     23    RelativeColorimetric = 1,
     24    Perceptual = 0,
     25 }
     26 
     27 use Intent::*;
     28 
     29 impl Default for Intent {
     30    fn default() -> Self {
     31        /* Chris Murphy (CM consultant) suggests this as a default in the event that we
     32         * cannot reproduce relative + Black Point Compensation.  BPC brings an
     33         * unacceptable performance overhead, so we go with perceptual. */
     34        Perceptual
     35    }
     36 }
     37 
     38 pub(crate) type s15Fixed16Number = i32;
     39 
     40 /* produces the nearest float to 'a' with a maximum error
     41 * of 1/1024 which happens for large values like 0x40000040 */
     42 #[inline]
     43 fn s15Fixed16Number_to_float(a: s15Fixed16Number) -> f32 {
     44    a as f32 / 65536.
     45 }
     46 
     47 #[inline]
     48 fn double_to_s15Fixed16Number(v: f64) -> s15Fixed16Number {
     49    (v * 65536.) as i32
     50 }
     51 
     52 #[cfg(feature = "c_bindings")]
     53 extern crate libc;
     54 #[cfg(feature = "c_bindings")]
     55 pub mod c_bindings;
     56 mod chain;
     57 mod gtest;
     58 mod iccread;
     59 mod matrix;
     60 mod transform;
     61 pub use iccread::qcms_CIE_xyY as CIE_xyY;
     62 pub use iccread::qcms_CIE_xyYTRIPLE as CIE_xyYTRIPLE;
     63 pub use iccread::Profile;
     64 pub use transform::DataType;
     65 pub use transform::Transform;
     66 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
     67 mod transform_avx;
     68 #[cfg(all(any(target_arch = "aarch64", target_arch = "arm"), feature = "neon"))]
     69 mod transform_neon;
     70 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
     71 mod transform_sse2;
     72 mod transform_util;