Skip to content
Snippets Groups Projects
Commit 2a83b000 authored by Kornel's avatar Kornel
Browse files

Debug print

parent e6eaf391
No related branches found
No related tags found
No related merge requests found
......@@ -31,5 +31,6 @@ fn main() {
let sync = Transform::new_flags_context(ThreadContext::new(), &profile, PixelFormat::RGB_8, &profile, PixelFormat::RGB_8, Intent::Saturation, Flags::NO_CACHE).unwrap();
let out = [0u8; 3];
sync.transform_pixels(&[[1u8,2,3]], &mut [out]);
let _: Box<dyn Sync> = Box::new(sync);
let tr: Box<dyn std::fmt::Debug + Sync> = Box::new(sync);
eprintln!("{:#?}", tr);
}
use std::rc::Rc;
use std::sync::Arc;
use super::*;
use std::fmt;
use std::ptr;
use std::mem;
use std::ffi::CStr;
......@@ -212,7 +213,7 @@ impl Drop for ThreadContext {
impl Default for GlobalContext {
fn default() -> Self {
Self::new()
}
}
}
impl Default for ThreadContext {
......@@ -221,6 +222,18 @@ impl Default for ThreadContext {
}
}
impl fmt::Debug for ThreadContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("ThreadContext")
}
}
impl fmt::Debug for GlobalContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("GlobalContext")
}
}
#[test]
fn context() {
let mut c = ThreadContext::new();
......
use super::*;
use crate::context::Context;
use std::fmt;
use std::path::Path;
use std::ptr;
use std::io;
......@@ -580,6 +581,18 @@ fn tags_write() {
});
}
impl fmt::Debug for Profile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut s = f.debug_struct("Profile");
let l = Locale::none();
s.field("Description", &self.info(InfoType::Description, l));
s.field("Manufacturer", &self.info(InfoType::Manufacturer, l));
s.field("Model", &self.info(InfoType::Model, l));
s.field("Copyright", &self.info(InfoType::Copyright, l));
s.finish()
}
}
#[test]
fn setters() {
let mut p = Profile::new_placeholder();
......@@ -592,6 +605,7 @@ fn setters() {
fn icc() {
let prof = Profile::new_xyz();
assert!(prof.icc().unwrap().len() > 300);
assert!(format!("{:?}", prof).contains("XYZ identity"));
}
#[test]
......
......@@ -2,6 +2,7 @@ use super::*;
use crate::context::Context;
use std::os::raw::c_void;
use std::marker::PhantomData;
use std::fmt;
/// Conversion between two ICC profiles.
///
......@@ -173,16 +174,6 @@ impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, Ctx: Conte
}
}
#[inline]
pub fn input_format(&self) -> PixelFormat {
unsafe { ffi::cmsGetTransformInputFormat(self.handle) as PixelFormat }
}
#[inline]
pub fn output_format(&self) -> PixelFormat {
unsafe { ffi::cmsGetTransformOutputFormat(self.handle) as PixelFormat }
}
#[inline]
pub fn new_flags_context(context: impl AsRef<Ctx>, input: &Profile<Ctx>, in_format: PixelFormat,
output: &Profile<Ctx>, out_format: PixelFormat,
......@@ -225,7 +216,19 @@ impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, Ctx: Conte
}
}
impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, C> Transform<InputPixelFormat, OutputPixelFormat, GlobalContext, C> {
impl<F, T, C, L> Transform<F, T, C, L> {
#[inline]
pub fn input_format(&self) -> PixelFormat {
unsafe { ffi::cmsGetTransformInputFormat(self.handle) as PixelFormat }
}
#[inline]
pub fn output_format(&self) -> PixelFormat {
unsafe { ffi::cmsGetTransformOutputFormat(self.handle) as PixelFormat }
}
}
impl<F, T, L> Transform<F, T, GlobalContext, L> {
/// Adaptation state for absolute colorimetric intent, on all but cmsCreateExtendedTransform.
///
/// See `ThreadContext::adaptation_state()`
......@@ -276,3 +279,18 @@ impl<F, T, C, L> Drop for Transform<F, T, C, L> {
}
}
impl<F, T, C, L> fmt::Debug for Transform<F, T, C, L> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut s = f.debug_struct(&format!(
"Transform<{}, {}, {}, {}>",
std::any::type_name::<F>(),
std::any::type_name::<T>(),
std::any::type_name::<C>(),
std::any::type_name::<L>(),
));
s.field("input_format", &self.input_format());
s.field("output_format", &self.output_format());
s.finish()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment