PhotoCraft: An open-source, photo editor written by scratch in pure Rust
CMYK ink compositing: isolated groups keep the special Fill rule
SBaksadf17ad752090
diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rsindex 1e0f6c844..db5a2c791 100644--- a/crates/compose/src/cmyk.rs+++ b/crates/compose/src/cmyk.rs@@ -514,7 +514,8 @@ fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx:composite_stack(&g.children, &mut content, cx);apply_mask(l, &mut content, cx);composite_clipped(clipped, &mut content, cx);- blend_into(backdrop, &content, l.blend, opacity, 1.0);+ // As the compositor blends an isolated group: Fill apart from opacity for the special eight.+ blend_into_fill(backdrop, &content, l, 1.0);return;}// Adjustment layers transform the backdrop, then blend the result back in.diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rsindex 962f266eb..4618429de 100644--- a/crates/compose/src/cmyk_tests.rs+++ b/crates/compose/src/cmyk_tests.rs@@ -295,8 +295,8 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka {_ => ref_own(l, x, y),};content = ref_clip(clipped, content, x, y);- // A layer's own blend (not a group's) for the special eight below 100% Fill.- if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) && !matches!(l.content, LayerContent::Group(_)) {+ // The special eight below 100% Fill, a layer's own blend and an isolated group's alike.+ if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) {return over_special_fill(l, b, content);}over_layer(l, b, content, op, Some((x, y)))@@ -372,6 +372,24 @@ fn masks_groups_and_clipping_match_the_reference() {assert_matches_reference(&d);}+/// An isolated group in one of the special eight below 100% Fill blends with Fill apart from+/// opacity, as the compositor blends it (the split route runs the compositor on stand-ins).+#[test]+fn isolated_groups_keep_the_special_fill_rule() {+ for mode in [BlendMode::Difference, BlendMode::LinearBurn, BlendMode::LinearDodge, BlendMode::LinearLight, BlendMode::ColorDodge] {+ assert!(crate::psblend::fill_is_special(mode), "{mode:?}");+ let mut d = doc(4, 2);+ d.layers.push(paper(4, 2, [0.2, 0.5, 0.1, 0.1]));+ let mut g = Layer::group("iso", vec![layer(&[(Rect::new(0, 0, 3, 2), [0.6, 0.1, 0.4, 0.2, 0.8])])]);+ g.blend = mode;+ g.opacity = 0.9;+ g.fill_opacity = 0.4;+ d.layers.push(g);+ assert_matches_reference(&d);+ assert_routes_agree(&d);+ }+}+#[test]fn unsupported_documents_fall_back() {let simple = || {