From 92aa5047cd8865c7806d06be0efb305d4f43445b Mon Sep 17 00:00:00 2001 From: varanus-salvator <262257003+varanus-salvator@users.noreply.github.com> Date: Thu, 15 Oct 2026 12:31:59 +0700 Subject: [PATCH 1/2] Bevel & Emboss: keep the Gloss Contour's Anti-aliased (antialiasGloss) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Photoshop stores Bevel & Emboss › Gloss Contour › Anti-aliased as `antialiasGloss` in the effect descriptor. The document model had no field for it, so import dropped it and export regenerated the bevel without it: once a bevel was edited (the Layer Style dialog re-applies all its settings), a saved PSD reopened in Photoshop with the gloss contour aliased. Add `Bevel::gloss_anti_alias` (serde default, so older .pcraft files load), read and write `antialiasGloss`, accept `glossAntiAlias` in layer.layerStyle.bevelEmboss and show the Anti-aliased checkbox next to the Gloss Contour in the dialog, as Photoshop does. Rendering is unchanged: contour anti-aliasing is not rendered for any effect yet. Co-Authored-By: Claude Opus 5.5 --- crates/compose/src/effects.rs | 1 + crates/compose/src/tests.rs | 4 ++++ crates/doc/src/effects.rs | 3 +++ crates/engine/src/layer_style.rs | 17 +++++++++++++++-- crates/format/tests/roundtrip.rs | 1 + crates/gpu/tests/parity.rs | 1 + crates/io/src/effects_map.rs | 3 +++ crates/ui-egui/examples/bevel_bench.rs | 1 + crates/ui-egui/examples/fx_bench.rs | 1 + crates/ui-egui/src/layer_style.rs | 21 ++++++++++++++++++++- docs/file-format-parity.md | 1 + 11 files changed, 51 insertions(+), 3 deletions(-) diff --git a/crates/compose/src/effects.rs b/crates/compose/src/effects.rs index 5acdd793144..a3d1bd998e2 100644 --- a/crates/compose/src/effects.rs +++ b/crates/compose/src/effects.rs @@ -2462,6 +2462,7 @@ mod tests { altitude: 30.0, use_global_light: false, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: photocraft_doc::FxCommon::new(BlendMode::Screen, 0.75), highlight_color: photocraft_color::Color::WHITE, shadow: photocraft_doc::FxCommon::new(BlendMode::Multiply, 0.75), diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index eb4b2507281..66a2947c174 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -1122,6 +1122,7 @@ fn satin_and_bevel_stay_inside_shape() { altitude: 30.0, use_global_light: false, gloss_contour: photocraft_doc::Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(photocraft_color::BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(photocraft_color::BlendMode::Multiply, 0.75), @@ -1298,6 +1299,7 @@ fn bevel_fx(style: photocraft_doc::BevelStyle, soften: f32) -> Effect { altitude: 30.0, use_global_light: false, gloss_contour: photocraft_doc::Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(photocraft_color::BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(photocraft_color::BlendMode::Multiply, 0.75), @@ -1538,6 +1540,7 @@ fn emboss_shades_the_composited_layer() { altitude: 30.0, use_global_light: false, gloss_contour: photocraft_doc::Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(photocraft_color::BlendMode::Normal, 1.0), highlight_color: Color::WHITE, shadow: FxCommon::new(photocraft_color::BlendMode::Multiply, 0.0), @@ -2547,6 +2550,7 @@ fn nested_parallel_fx_doc() -> Document { altitude: 32.0, use_global_light: false, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(BlendMode::Multiply, 0.75), diff --git a/crates/doc/src/effects.rs b/crates/doc/src/effects.rs index 6ae790e26c3..d242e0e5169 100644 --- a/crates/doc/src/effects.rs +++ b/crates/doc/src/effects.rs @@ -213,6 +213,9 @@ pub struct Bevel { pub altitude: f32, pub use_global_light: bool, pub gloss_contour: Contour, + /// Gloss Contour › Anti-aliased (PSD `antialiasGloss`). + #[serde(default)] + pub gloss_anti_alias: bool, pub highlight: FxCommon, pub highlight_color: Color, pub shadow: FxCommon, diff --git a/crates/engine/src/layer_style.rs b/crates/engine/src/layer_style.rs index 95b54768509..19d19db26ba 100644 --- a/crates/engine/src/layer_style.rs +++ b/crates/engine/src/layer_style.rs @@ -98,7 +98,7 @@ pub fn effect_defaults(kind: &str) -> Value { } "patternOverlay" => json!({"blend": "Normal", "opacity": 100, "pattern": "", "angle": 0, "scale": 100, "link": true}), "bevelEmboss" => { - json!({"style": "inner", "technique": "smooth", "depth": 100, "direction": "up", "size": 5, "soften": 0, "angle": 120, "useGlobalLight": true, "altitude": 30, "glossContour": "Linear", "contour": false, "contourName": "Linear", "contourRange": 50, "contourAntiAlias": false}) + json!({"style": "inner", "technique": "smooth", "depth": 100, "direction": "up", "size": 5, "soften": 0, "angle": 120, "useGlobalLight": true, "altitude": 30, "glossContour": "Linear", "glossAntiAlias": false, "contour": false, "contourName": "Linear", "contourRange": 50, "contourAntiAlias": false}) } "satin" => { json!({"blend": "Multiply", "color": "#000000", "opacity": 50, "angle": 19, "distance": 11, "size": 14, "contour": "Linear", "antiAlias": true, "invert": true}) @@ -544,6 +544,7 @@ fn fresh_effect(kind: &str) -> Option { altitude: 30.0, use_global_light: true, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(BlendMode::Multiply, 0.75), @@ -789,6 +790,7 @@ pub fn overlay_effect(fx: &mut Effect, p: &Value) { bv.use_global_light = x; } set_contour(p, "glossContour", &mut bv.gloss_contour); + set_bool(p, "glossAntiAlias", &mut bv.gloss_anti_alias); // The Contour element: `contour` turns it on/off; its curve, Range and // Anti-aliased edit the element in place, so an imported curve survives. match b_of(p, "contour") { @@ -1021,7 +1023,7 @@ pub fn specs() -> Vec { style_cmd!( "bevelEmboss", "Bevel & Emboss…", - r##"{"style":"inner|outer|emboss|pillow|stroke","technique":"smooth|chiselHard|chiselSoft","contour":bool,"contourName":name|curve,"contourRange":1..100=50,"contourAntiAlias":bool,"glossContour":name|curve,"texture":pattern id|name?,"textureScale":1..1000=100,"textureDepth":-1000..1000=100,"textureInvert":bool,"textureLink":bool=true,"depth":1..1000=100,"direction":"up|down","size":px=5,"soften":px,"angle":deg,"altitude":deg,"add":bool}"## + r##"{"style":"inner|outer|emboss|pillow|stroke","technique":"smooth|chiselHard|chiselSoft","contour":bool,"contourName":name|curve,"contourRange":1..100=50,"contourAntiAlias":bool,"glossContour":name|curve,"glossAntiAlias":bool,"texture":pattern id|name?,"textureScale":1..1000=100,"textureDepth":-1000..1000=100,"textureInvert":bool,"textureLink":bool=true,"depth":1..1000=100,"direction":"up|down","size":px=5,"soften":px,"angle":deg,"altitude":deg,"add":bool}"## ), style_cmd!( "satin", @@ -1137,6 +1139,17 @@ mod tests { assert_eq!((t.name.as_str(), t.depth, t.invert), ("Bubbles", -2.0, true)); } + #[test] + fn bevel_gloss_anti_alias_is_a_param() { + let mut s = session(); + s.execute("layer.layerStyle.bevelEmboss", json!({"glossContour": "Ring - Double", "glossAntiAlias": true})).unwrap(); + let Effect::BevelEmboss(b) = &effects(&s)[0] else { panic!() }; + assert!(b.gloss_anti_alias); + s.execute("layer.layerStyle.bevelEmboss", json!({"glossAntiAlias": false})).unwrap(); + let Effect::BevelEmboss(b) = &effects(&s)[0] else { panic!() }; + assert!(!b.gloss_anti_alias); + } + #[test] fn every_style_command_adds_its_effect() { for kind in ["dropShadow", "innerShadow", "outerGlow", "innerGlow", "stroke", "colorOverlay", "gradientOverlay", "bevelEmboss", "satin"] { diff --git a/crates/format/tests/roundtrip.rs b/crates/format/tests/roundtrip.rs index f78e93947e2..28236cf5cce 100644 --- a/crates/format/tests/roundtrip.rs +++ b/crates/format/tests/roundtrip.rs @@ -579,6 +579,7 @@ fn channel_restrictions_and_bevel_elements_roundtrip() { altitude: 40.0, use_global_light: false, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: photocraft_doc::FxCommon::new(photocraft_color::BlendMode::Screen, 0.7), highlight_color: photocraft_color::Color::WHITE, shadow: photocraft_doc::FxCommon::new(photocraft_color::BlendMode::Multiply, 0.6), diff --git a/crates/gpu/tests/parity.rs b/crates/gpu/tests/parity.rs index 84d3d0e9370..9e3643fde8e 100644 --- a/crates/gpu/tests/parity.rs +++ b/crates/gpu/tests/parity.rs @@ -1330,6 +1330,7 @@ fn bevel(style: BevelStyle, up: bool, size: f32, soften: f32) -> Bevel { altitude: 35.0, use_global_light: true, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(BlendMode::Screen, 0.8), highlight_color: Color::rgb(1.0, 1.0, 0.9), shadow: FxCommon::new(BlendMode::Multiply, 0.7), diff --git a/crates/io/src/effects_map.rs b/crates/io/src/effects_map.rs index 00815e2c837..b8de5a5c37b 100644 --- a/crates/io/src/effects_map.rs +++ b/crates/io/src/effects_map.rs @@ -239,6 +239,7 @@ fn parse_bevel(d: &Descriptor) -> Bevel { altitude: f(d, "Lald", 30.0), use_global_light: !matches!(d.get("uglg"), Some(Value::Boolean(false))), gloss_contour: contour(d, "TrnS"), + gloss_anti_alias: bool_of(d, "antialiasGloss"), highlight: FxCommon { enabled: true, blend: blend_of(d, "hglM", BlendMode::Screen), opacity: pct(d, "hglO", 0.75) }, highlight_color: get_desc(d, "hglC").and_then(color_from_desc).unwrap_or(Color::WHITE), shadow: FxCommon { enabled: true, blend: blend_of(d, "sdwM", BlendMode::Multiply), opacity: pct(d, "sdwO", 0.75) }, @@ -482,6 +483,7 @@ fn write_one(e: &Effect) -> (&'static str, Descriptor) { .with("blur", unit(b"#Pxl", b.size)) .with("bvlD", Value::Enumerated { type_id: Id::new("BESs"), value: Id::new(if b.up { "In " } else { "Out " }) }) .with("TrnS", contour_value(&b.gloss_contour)) + .with("antialiasGloss", Value::Boolean(b.gloss_anti_alias)) .with("Sftn", unit(b"#Pxl", b.soften)); let d = match &b.contour { Some(c) => d @@ -720,6 +722,7 @@ mod tests { altitude: 40.0, use_global_light: false, gloss_contour: Contour::Linear, + gloss_anti_alias: true, highlight: FxCommon::new(BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(BlendMode::Multiply, 0.6), diff --git a/crates/ui-egui/examples/bevel_bench.rs b/crates/ui-egui/examples/bevel_bench.rs index 5d2d09dc6ba..15c76e6d35c 100644 --- a/crates/ui-egui/examples/bevel_bench.rs +++ b/crates/ui-egui/examples/bevel_bench.rs @@ -52,6 +52,7 @@ fn bevel(size: f32) -> Effect { altitude: 32.0, use_global_light: false, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(BlendMode::Multiply, 0.75), diff --git a/crates/ui-egui/examples/fx_bench.rs b/crates/ui-egui/examples/fx_bench.rs index aa2bf61b15c..7e774499383 100644 --- a/crates/ui-egui/examples/fx_bench.rs +++ b/crates/ui-egui/examples/fx_bench.rs @@ -59,6 +59,7 @@ fn effects() -> Vec { altitude: 30.0, use_global_light: true, gloss_contour: Contour::Linear, + gloss_anti_alias: false, highlight: FxCommon::new(BlendMode::Screen, 0.75), highlight_color: Color::WHITE, shadow: FxCommon::new(BlendMode::Multiply, 0.75), diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs index d876c182789..1e8402b78d2 100644 --- a/crates/ui-egui/src/layer_style.rs +++ b/crates/ui-egui/src/layer_style.rs @@ -172,7 +172,7 @@ fn spec(kind: &str) -> &'static [(&'static str, &'static str, P)] { ("angle", "Angle", P::Angle), ("useGlobalLight", "Use Global Light", P::Check), ("altitude", "Altitude", P::Slider(0.0, 90.0, "°")), - ("glossContour", "Gloss Contour", P::Contour(None)), + ("glossContour", "Gloss Contour", P::Contour(Some("glossAntiAlias"))), // Bevel & Emboss › Contour element. ("contour", "Contour", P::Check), ("contourName", "", P::Contour(Some("contourAntiAlias"))), @@ -355,6 +355,7 @@ fn values_of(e: &Effect, light: f32) -> Value { set(&mut v, "altitude", json!(b.altitude)); set(&mut v, "direction", json!(if b.up { "up" } else { "down" })); set(&mut v, "glossContour", photocraft_engine::layer_style::contour_param(&b.gloss_contour)); + set(&mut v, "glossAntiAlias", json!(b.gloss_anti_alias)); set(&mut v, "contour", json!(b.contour.is_some())); if let Some(c) = &b.contour { set(&mut v, "contourName", photocraft_engine::layer_style::contour_param(&c.contour)); @@ -1634,6 +1635,24 @@ mod tests { ); } + #[test] + fn bevel_gloss_anti_alias_survives_the_dialog() { + let mut s = session(); + s.execute("layer.layerStyle.bevelEmboss", json!({"glossContour": "Ring - Double", "glossAntiAlias": true})).unwrap(); + let st = s.active().unwrap(); + let id = st.active_layer.unwrap(); + let mut f = initial_fields(st.doc.layer(id).unwrap(), None, st.doc.global_light.angle); + assert_eq!(effects_of(&f)[0]["params"]["glossAntiAlias"], json!(true)); + // Editing another setting keeps the gloss contour's Anti-aliased. + set_param(&mut f, "fx1", "size", json!(12)); + apply(&f, |cmd, p| s.execute(cmd, p).map_err(|e| e.to_string())).unwrap(); + let st = s.active().unwrap(); + let items = &st.doc.layer(id).unwrap().effects.items; + let Some(photocraft_doc::Effect::BevelEmboss(b)) = items.first() else { panic!("{items:?}") }; + assert_eq!(b.size, 12.0); + assert!(b.gloss_anti_alias); + } + #[test] fn preview_applies_the_style_without_touching_the_document() { let s = session(); diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index ba746237098..fe0283845c9 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-15 | minor | Bevel & Emboss Gloss Contour › Anti-aliased (`antialiasGloss`) is read and written, set by `glossAntiAlias` and shown in the Layer Style dialog; a PSD whose bevel is edited no longer loses it. Rendering still ignores contour anti-aliasing, as for the other effects' contours | | 2026-10-14 | minor | PSD smart filter masks: Photoshop stores a smart object's filtered pixels without its filter mask and mixes the unfiltered ones (`FEid`) back in; import now mixes them and export writes them that way, so sf-filter-mask-hard, -gradient and sf-stack-blend-and-mask pass; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | Lossy DNG (compression 34892) decodes: 8-bit baseline JPEG tiles and strips, CFA and LinearRaw, partial edge tiles; the stored values take the normal levels and LinearizationTable (FILE-215-11, lossy DNG part) | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | From 723dbe943f1c0f339d27c9ed5947f8bb3eb70e15 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 20 Oct 2026 23:49:52 +0200 Subject: [PATCH 2/2] Integration: test that PSD export writes antialiasGloss (#5990) lfx2_roundtrip_all_kinds compares re-serialized bytes, so dropping the new `.with("antialiasGloss", ...)` line from write_one still passed every test: both sides then lose the flag the same way. The new test writes a Bevel with the Gloss Contour's Anti-aliased on and reads the flag back; it fails with that line removed. Co-authored-by: varanus-salvator <262257003+varanus-salvator@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/io/src/effects_map.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/io/src/effects_map.rs b/crates/io/src/effects_map.rs index b8de5a5c37b..88678dd25a4 100644 --- a/crates/io/src/effects_map.rs +++ b/crates/io/src/effects_map.rs @@ -739,6 +739,16 @@ mod tests { assert_eq!(write_lfx2(true, a), write_lfx2(true, b)); } + /// `approx` compares re-serialized bytes, so a field the writer drops looks equal on both + /// sides: read the Gloss Contour's Anti-aliased back directly. + #[test] + fn bevel_gloss_anti_alias_is_written() { + let fx: Vec = sample_effects().into_iter().filter(|e| matches!(e, Effect::BevelEmboss(_))).collect(); + assert!(matches!(fx.as_slice(), [Effect::BevelEmboss(b)] if b.gloss_anti_alias)); + let (_, back) = parse_lfx2(&write_lfx2(false, &fx)).unwrap(); + assert!(matches!(back.as_slice(), [Effect::BevelEmboss(b)] if b.gloss_anti_alias), "{back:?}"); + } + #[test] fn lfx2_roundtrip_all_kinds() { let fx = sample_effects();