Skip to content

Commit c7648e8

Browse files
committed
style: cargo fmt
1 parent f7252d0 commit c7648e8

File tree

4 files changed

+81
-73
lines changed

4 files changed

+81
-73
lines changed

imageflow_abi/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,12 @@ pub unsafe extern "C" fn imageflow_json_response_read(
838838
pub unsafe extern "C" fn imageflow_json_response_destroy(
839839
context: *mut ThreadSafeContext,
840840
response: *mut JsonResponse,
841-
) -> bool { unsafe {
842-
let context = context!(context);
843-
imageflow_context_memory_free(context, response as *mut libc::c_void, ptr::null(), 0)
844-
}}
841+
) -> bool {
842+
unsafe {
843+
let context = context!(context);
844+
imageflow_context_memory_free(context, response as *mut libc::c_void, ptr::null(), 0)
845+
}
846+
}
845847

846848
/// Requests cancellation of any running or future operations on this context.
847849
///

imageflow_core/src/codecs/lcms2_transform.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@ impl Lcms2TransformCache {
2525
_context_id: lcms2_sys::Context,
2626
error_code: u32,
2727
text: *const core::ffi::c_char,
28-
) { unsafe {
29-
if text.is_null() {
30-
return;
31-
}
32-
let text_str =
33-
std::ffi::CStr::from_ptr(text).to_str().unwrap_or("LCMS error message not valid UTF8");
34-
let message = format!("Error {}: {}", error_code, text_str);
28+
) {
29+
unsafe {
30+
if text.is_null() {
31+
return;
32+
}
33+
let text_str = std::ffi::CStr::from_ptr(text)
34+
.to_str()
35+
.unwrap_or("LCMS error message not valid UTF8");
36+
let message = format!("Error {}: {}", error_code, text_str);
3537

36-
LAST_PROFILE_ERROR_MESSAGE.with(|m| {
37-
*m.borrow_mut() = Some(message);
38-
})
39-
}}
38+
LAST_PROFILE_ERROR_MESSAGE.with(|m| {
39+
*m.borrow_mut() = Some(message);
40+
})
41+
}
42+
}
4043

4144
fn create_thread_context() -> ThreadContext {
4245
let mut context = ThreadContext::new();

imageflow_core/src/codecs/source_profile.rs

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -190,67 +190,71 @@ impl SourceProfile {
190190
/// The `profile_buffer` pointer in `color` must be valid for `buffer_length` bytes
191191
/// if `source` is `ICCP` or `ICCP_GRAY`.
192192
#[cfg(feature = "c-codecs")]
193-
pub unsafe fn from_decoder_color_info(color: &DecoderColorInfo) -> Self { unsafe {
194-
match color.source {
195-
ColorProfileSource::Null | ColorProfileSource::sRGB => SourceProfile::Srgb,
196-
ColorProfileSource::ICCP => {
197-
if color.profile_buffer.is_null() || color.buffer_length == 0 {
198-
return SourceProfile::Srgb;
199-
}
200-
let bytes =
201-
std::slice::from_raw_parts(color.profile_buffer, color.buffer_length).to_vec();
202-
SourceProfile::IccProfile(bytes)
203-
}
204-
ColorProfileSource::ICCP_GRAY => {
205-
if color.profile_buffer.is_null() || color.buffer_length == 0 {
206-
return SourceProfile::Srgb;
207-
}
208-
let bytes =
209-
std::slice::from_raw_parts(color.profile_buffer, color.buffer_length).to_vec();
210-
SourceProfile::IccProfileGray(bytes)
211-
}
212-
ColorProfileSource::GAMA_CHRM => {
213-
let g = color.gamma;
214-
let wx = color.white_point.x;
215-
let wy = color.white_point.y;
216-
let rx = color.primaries.Red.x;
217-
let ry = color.primaries.Red.y;
218-
let gx = color.primaries.Green.x;
219-
let gy = color.primaries.Green.y;
220-
let bx = color.primaries.Blue.x;
221-
let by = color.primaries.Blue.y;
222-
// Reject degenerate values: NaN, infinity, zero gamma, or y=0
223-
let all_finite = [wx, wy, rx, ry, gx, gy, bx, by].iter().all(|v| v.is_finite());
224-
if g <= 0.0
225-
|| !g.is_finite()
226-
|| !all_finite
227-
|| wy == 0.0
228-
|| ry == 0.0
229-
|| gy == 0.0
230-
|| by == 0.0
231-
{
232-
return SourceProfile::Srgb;
193+
pub unsafe fn from_decoder_color_info(color: &DecoderColorInfo) -> Self {
194+
unsafe {
195+
match color.source {
196+
ColorProfileSource::Null | ColorProfileSource::sRGB => SourceProfile::Srgb,
197+
ColorProfileSource::ICCP => {
198+
if color.profile_buffer.is_null() || color.buffer_length == 0 {
199+
return SourceProfile::Srgb;
200+
}
201+
let bytes =
202+
std::slice::from_raw_parts(color.profile_buffer, color.buffer_length)
203+
.to_vec();
204+
SourceProfile::IccProfile(bytes)
233205
}
234-
// If gamma is neutral and primaries match sRGB, this is effectively
235-
// sRGB — no transform needed. This catches gAMA-only PNGs where the
236-
// C code synthesized sRGB primaries.
237-
if is_neutral_gamma(g) && is_srgb_primaries([wx, wy, rx, ry, gx, gy, bx, by]) {
238-
return SourceProfile::Srgb;
206+
ColorProfileSource::ICCP_GRAY => {
207+
if color.profile_buffer.is_null() || color.buffer_length == 0 {
208+
return SourceProfile::Srgb;
209+
}
210+
let bytes =
211+
std::slice::from_raw_parts(color.profile_buffer, color.buffer_length)
212+
.to_vec();
213+
SourceProfile::IccProfileGray(bytes)
239214
}
240-
SourceProfile::GammaPrimaries {
241-
gamma: g,
242-
white_x: wx,
243-
white_y: wy,
244-
red_x: rx,
245-
red_y: ry,
246-
green_x: gx,
247-
green_y: gy,
248-
blue_x: bx,
249-
blue_y: by,
215+
ColorProfileSource::GAMA_CHRM => {
216+
let g = color.gamma;
217+
let wx = color.white_point.x;
218+
let wy = color.white_point.y;
219+
let rx = color.primaries.Red.x;
220+
let ry = color.primaries.Red.y;
221+
let gx = color.primaries.Green.x;
222+
let gy = color.primaries.Green.y;
223+
let bx = color.primaries.Blue.x;
224+
let by = color.primaries.Blue.y;
225+
// Reject degenerate values: NaN, infinity, zero gamma, or y=0
226+
let all_finite = [wx, wy, rx, ry, gx, gy, bx, by].iter().all(|v| v.is_finite());
227+
if g <= 0.0
228+
|| !g.is_finite()
229+
|| !all_finite
230+
|| wy == 0.0
231+
|| ry == 0.0
232+
|| gy == 0.0
233+
|| by == 0.0
234+
{
235+
return SourceProfile::Srgb;
236+
}
237+
// If gamma is neutral and primaries match sRGB, this is effectively
238+
// sRGB — no transform needed. This catches gAMA-only PNGs where the
239+
// C code synthesized sRGB primaries.
240+
if is_neutral_gamma(g) && is_srgb_primaries([wx, wy, rx, ry, gx, gy, bx, by]) {
241+
return SourceProfile::Srgb;
242+
}
243+
SourceProfile::GammaPrimaries {
244+
gamma: g,
245+
white_x: wx,
246+
white_y: wy,
247+
red_x: rx,
248+
red_y: ry,
249+
green_x: gx,
250+
green_y: gy,
251+
blue_x: bx,
252+
blue_y: by,
253+
}
250254
}
251255
}
252256
}
253-
}}
257+
}
254258

255259
/// Returns true if this profile is sRGB (no transform needed).
256260
pub fn is_srgb(&self) -> bool {

imageflow_core/src/flow/nodes/round_corners.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ impl NodeDefMutateBitmap for RoundImageCornersMut {
6464
"imazen.round_image_corners_mut"
6565
}
6666
fn mutate(&self, c: &Context, bitmap_key: BitmapKey, p: &NodeParams) -> Result<()> {
67-
if let NodeParams::Json(s::Node::RoundImageCorners { background_color, radius }) = p
68-
{
67+
if let NodeParams::Json(s::Node::RoundImageCorners { background_color, radius }) = p {
6968
let bitmaps = c.borrow_bitmaps().map_err(|e| e.at(here!()))?;
7069
let mut bitmap_bitmap =
7170
bitmaps.try_borrow_mut(bitmap_key).map_err(|e| e.at(here!()))?;

0 commit comments

Comments
 (0)