mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1695549 - Run cargo fmt on qcms. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D106739
This commit is contained in:
parent
168f75a38e
commit
62f4683595
@ -177,13 +177,7 @@ mod gtest {
|
||||
unsafe { qcms_profile_precache_output_transform(&mut *other) };
|
||||
|
||||
let transform = unsafe {
|
||||
qcms_transform_create(
|
||||
&mut *sRGB_profile,
|
||||
RGB8,
|
||||
&mut *other,
|
||||
RGB8,
|
||||
Perceptual,
|
||||
)
|
||||
qcms_transform_create(&mut *sRGB_profile, RGB8, &mut *other, RGB8, Perceptual)
|
||||
};
|
||||
let mut data: [u8; 120] = [0; 120];
|
||||
|
||||
@ -210,13 +204,7 @@ mod gtest {
|
||||
unsafe { qcms_profile_precache_output_transform(&mut *other) };
|
||||
|
||||
let transform = unsafe {
|
||||
qcms_transform_create(
|
||||
&mut *other,
|
||||
GrayA8,
|
||||
&mut *sRGB_profile,
|
||||
RGBA8,
|
||||
Perceptual,
|
||||
)
|
||||
qcms_transform_create(&mut *other, GrayA8, &mut *sRGB_profile, RGBA8, Perceptual)
|
||||
};
|
||||
assert!(!transform.is_null());
|
||||
|
||||
@ -294,9 +282,8 @@ mod gtest {
|
||||
unsafe { qcms_profile_precache_output_transform(&mut *srgb_profile) };
|
||||
|
||||
let intent = unsafe { qcms_profile_get_rendering_intent(&*profile) };
|
||||
let transform = unsafe {
|
||||
qcms_transform_create(&*profile, RGB8, &*srgb_profile, RGB8, intent)
|
||||
};
|
||||
let transform =
|
||||
unsafe { qcms_transform_create(&*profile, RGB8, &*srgb_profile, RGB8, intent) };
|
||||
|
||||
assert_ne!(transform, std::ptr::null_mut());
|
||||
|
||||
@ -820,15 +807,7 @@ mod gtest {
|
||||
// manually edited using iccToXML/iccFromXML
|
||||
let output = profile_from_path("B2A0-ident.icc");
|
||||
|
||||
let transform = unsafe {
|
||||
qcms_transform_create(
|
||||
&*input,
|
||||
RGB8,
|
||||
&*output,
|
||||
RGB8,
|
||||
Perceptual,
|
||||
)
|
||||
};
|
||||
let transform = unsafe { qcms_transform_create(&*input, RGB8, &*output, RGB8, Perceptual) };
|
||||
let src = [0u8, 60, 195];
|
||||
let mut dst = [0u8, 0, 0];
|
||||
unsafe {
|
||||
@ -893,9 +872,11 @@ mod gtest {
|
||||
let D65 = qcms_white_point_sRGB();
|
||||
let mut mem = std::ptr::null_mut();
|
||||
let mut size = 0;
|
||||
unsafe { qcms_data_create_rgb_with_gamma(D65, Rec709Primaries, 2.2, &mut mem, &mut size); }
|
||||
unsafe {
|
||||
qcms_data_create_rgb_with_gamma(D65, Rec709Primaries, 2.2, &mut mem, &mut size);
|
||||
}
|
||||
assert_ne!(size, 0);
|
||||
unsafe { libc::free(mem) } ;
|
||||
unsafe { libc::free(mem) };
|
||||
}
|
||||
}
|
||||
|
||||
@ -905,13 +886,8 @@ mod test {
|
||||
fn identity() {
|
||||
let p1 = crate::Profile::new_sRGB();
|
||||
let p2 = crate::Profile::new_sRGB();
|
||||
let xfm = crate::Transform::new(
|
||||
&p1,
|
||||
&p2,
|
||||
crate::DataType::RGB8,
|
||||
crate::Intent::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let xfm = crate::Transform::new(&p1, &p2, crate::DataType::RGB8, crate::Intent::default())
|
||||
.unwrap();
|
||||
let mut data = [4, 30, 80];
|
||||
xfm.apply(&mut data);
|
||||
assert_eq!(data, [4, 30, 80]);
|
||||
@ -920,13 +896,8 @@ mod test {
|
||||
fn D50() {
|
||||
let p1 = crate::Profile::new_sRGB();
|
||||
let p2 = crate::Profile::new_XYZD50();
|
||||
let xfm = crate::Transform::new(
|
||||
&p1,
|
||||
&p2,
|
||||
crate::DataType::RGB8,
|
||||
crate::Intent::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let xfm = crate::Transform::new(&p1, &p2, crate::DataType::RGB8, crate::Intent::default())
|
||||
.unwrap();
|
||||
let mut data = [4, 30, 80];
|
||||
xfm.apply(&mut data);
|
||||
assert_eq!(data, [4, 4, 15]);
|
||||
|
@ -22,12 +22,15 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::Arc,
|
||||
convert::TryInto,
|
||||
};
|
||||
|
||||
use crate::{double_to_s15Fixed16Number, transform::{set_rgb_colorants, PrecacheOuput}};
|
||||
use crate::{
|
||||
double_to_s15Fixed16Number,
|
||||
transform::{set_rgb_colorants, PrecacheOuput},
|
||||
};
|
||||
use crate::{matrix::Matrix, s15Fixed16Number, s15Fixed16Number_to_float, Intent, Intent::*};
|
||||
|
||||
pub static SUPPORTS_ICCV4: AtomicBool = AtomicBool::new(cfg!(feature = "iccv4-enabled"));
|
||||
@ -178,7 +181,7 @@ fn invalid_source(mut mem: &mut MemSource, reason: &'static str) {
|
||||
mem.invalid_reason = Some(reason);
|
||||
}
|
||||
fn read_u32(mem: &mut MemSource, offset: usize) -> u32 {
|
||||
let val = mem.buf.get(offset..offset+4);
|
||||
let val = mem.buf.get(offset..offset + 4);
|
||||
if let Some(val) = val {
|
||||
let val = val.try_into().unwrap();
|
||||
u32::from_be_bytes(val)
|
||||
@ -188,7 +191,7 @@ fn read_u32(mem: &mut MemSource, offset: usize) -> u32 {
|
||||
}
|
||||
}
|
||||
fn read_u16(mem: &mut MemSource, offset: usize) -> u16 {
|
||||
let val = mem.buf.get(offset..offset+2);
|
||||
let val = mem.buf.get(offset..offset + 2);
|
||||
if let Some(val) = val {
|
||||
let val = val.try_into().unwrap();
|
||||
u16::from_be_bytes(val)
|
||||
@ -218,14 +221,14 @@ fn read_uInt16Number(mem: &mut MemSource, offset: usize) -> uInt16Number {
|
||||
pub fn write_u32(mem: &mut [u8], offset: usize, value: u32) {
|
||||
// we use get() and expect() instead of [..] so there's only one call to panic
|
||||
// instead of two
|
||||
mem.get_mut(offset..offset+std::mem::size_of_val(&value))
|
||||
mem.get_mut(offset..offset + std::mem::size_of_val(&value))
|
||||
.expect("OOB")
|
||||
.copy_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
pub fn write_u16(mem: &mut [u8], offset: usize, value: u16) {
|
||||
// we use get() and expect() instead of [..] so there's only one call to panic
|
||||
// intead of two
|
||||
mem.get_mut(offset..offset+std::mem::size_of_val(&value))
|
||||
mem.get_mut(offset..offset + std::mem::size_of_val(&value))
|
||||
.expect("OOB")
|
||||
.copy_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
|
@ -1337,7 +1337,7 @@ pub fn transform_create(
|
||||
debug_assert!(transform.transform_fn.is_some());
|
||||
Some(transform)
|
||||
}
|
||||
/// A transform from an input profile to an output one.
|
||||
/// A transform from an input profile to an output one.
|
||||
pub struct Transform {
|
||||
ty: DataType,
|
||||
xfm: Box<qcms_transform>,
|
||||
@ -1345,12 +1345,7 @@ pub struct Transform {
|
||||
|
||||
impl Transform {
|
||||
/// Create a new transform from `input` to `output` for pixels of `DataType` `ty` with `intent`
|
||||
pub fn new(
|
||||
input: &Profile,
|
||||
output: &Profile,
|
||||
ty: DataType,
|
||||
intent: Intent,
|
||||
) -> Option<Self> {
|
||||
pub fn new(input: &Profile, output: &Profile, ty: DataType, intent: Intent) -> Option<Self> {
|
||||
transform_create(input, ty, output, ty, intent).map(|xfm| Transform { ty, xfm })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user