mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Merge remote-tracking branch 'origin/main' into fix/tiff-alpha-compression
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
7fae49548d
75 files changed
+697
-151
No files matched your search
@@ -131,7 +131,6 @@ Then append a terse entry to `log/devlog.md` (what landed, numbers, what's still
|
||||
- `../craftrules/release/playbook.md`: how every storytold app builds signed release binaries (the canonical recipe; `docs/release-playbook.md` just points there); `docs/releasing.md` is PhotoCraft's specifics.
|
||||
- `plan/` (local, gitignored): research, parity plan, execution plan, estimates.
|
||||
- `log/` (local, gitignored): the dev log.
|
||||
-
|
||||
|
||||
## 8. Keeping the native format complete
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ Every screenshot here is the real app at work on public-domain art, rendered off
|
||||
</td>
|
||||
<td width="33%" valign="top">
|
||||
<h4>🗃️ Layers, done properly</h4>
|
||||
Groups, clipping masks, pixel and vector masks, fill layers (solid, gradient and pattern), adjustment layers, live smart objects with smart filters and lossless transforms and warps, multi-layer selection with align, distribute and link, alpha channels and Quick Mask, 27 Photoshop blend modes plus six Paint.NET variants, opacity and fill, locks, colour labels, layer filters, merge, flatten, rasterize, Layer via Copy/Cut, Paste Into.
|
||||
Groups, clipping masks, pixel and vector masks, fill layers (solid, gradient and pattern), adjustment layers, live smart objects with smart filters and lossless transforms and warps, multi-layer selection with align, distribute and link, alpha channels and Quick Mask, 27 Photoshop blend modes plus six Paint.NET variants, opacity and fill, locks, colour labels, a layer kind filter, merge, flatten, rasterize, Layer via Copy/Cut, Paste Into.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
+4
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
**Stage: alpha** · next: beta, ~30 points (ready for real work ~45% → ~75%, with reliable PSD) and ~1,100–1,800 h away
|
||||
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-11 · **Change:** minor (toolbox count 56 of 68, 12 missing) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-13 · **Change:** minor (oracle floor 145 of 258 and 953 open issues, as in gaps.md and on GitHub; toolbox count 56 of 68, 12 missing) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
PhotoCraft's one-page summary of how close it is to Adobe Photoshop 2026 (27.11.0, measured from
|
||||
the installed app on 2026-10-10) at version 0.6.0. Detail: [target-app parity](docs/target-app-parity.md)
|
||||
@@ -40,7 +40,7 @@ the one above. About 80% parallelizes (independent crates and command modules);
|
||||
architecture and the PSD writer are the serial parts.
|
||||
|
||||
**Why alpha.** Core workflows (open, layer, select, paint, adjust, filter, type, save) work end to
|
||||
end, and breadth is high, but users of 0.5/0.6 have 579 open issues, 22 of 25 performance budgets
|
||||
end, and breadth is high, but 953 issues are open (2026-10-13), 22 of 25 performance budgets
|
||||
are missed, and PSDs we write are not yet reliably accepted by Photoshop (#1281, #2469). Beta
|
||||
needs ~75% ready and no blocking PSD gap. The [alpha gate](docs/roadmap.md#alpha-gate) passes: all six core workflows
|
||||
(retouch, composite, cut-out, design, paint, PSD exchange) complete end to end and save and reopen;
|
||||
@@ -110,7 +110,7 @@ Also shipped: Traditional Chinese, Russian, Ukrainian, Czech, Polish, Greek, Dut
|
||||
|
||||
| Rank | Milestone | Estimate |
|
||||
|---|---|---:|
|
||||
| 1 | PSD that Photoshop trusts: Save As corruption, Photoshop re-open check, Photoshop-oracle floor 133 → 200+ of 256 | 150–250 h |
|
||||
| 1 | PSD that Photoshop trusts: Save As corruption, Photoshop re-open check, Photoshop-oracle floor 145 → 200+ of 258 | 150–250 h |
|
||||
| 2 | Performance budgets: the 22 over-budget scenarios and the 150-layer GPU crash | 200–350 h |
|
||||
| 3 | User bug backlog to under 100 open | 250–400 h |
|
||||
| 4 | Brush and transform feel (brush-parity, ui-parity rows) | 160–290 h |
|
||||
@@ -135,6 +135,7 @@ Detail and the next releases: [docs/roadmap.md](docs/roadmap.md).
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-13 | minor | Focus item 1 quoted the oracle floor as 133 of 256; it is 145 of 258 (`crates/io/tests/corpus.rs`, gaps.md G1). Open issues 579 → 953 (2026-10-13) |
|
||||
| 2026-10-11 | minor | Toolbox count 56 of 68 (12 missing) with the Convert Point tool (#3204) |
|
||||
| 2026-10-10 | minor | Readiness by audience with hours per tier |
|
||||
| 2026-10-10 | minor | Mainstream-practitioner and essentials-user numbers added |
|
||||
|
||||
+11
-3
@@ -600,6 +600,13 @@ impl FilterParams {
|
||||
self.halo() == Halo::Bounds
|
||||
}
|
||||
|
||||
/// Whether the filter renders new pixels without reading the layer's own (Fibers): it fills
|
||||
/// the reference bounds even where the layer is transparent, as Photoshop's does on an
|
||||
/// empty layer, while still reading no neighbourhood.
|
||||
pub fn renders_from_nothing(&self) -> bool {
|
||||
matches!(self, FilterParams::Fibers { .. })
|
||||
}
|
||||
|
||||
/// Human-readable name.
|
||||
pub fn label(&self) -> &'static str {
|
||||
match self {
|
||||
@@ -905,12 +912,13 @@ pub fn kernel(params: &FilterParams, src: &Image, out: Rect, ctx: &Ctx) -> Vec<f
|
||||
pub const TILE: i32 = 256;
|
||||
|
||||
/// The area a filter writes for a layer whose pixels cover `content`:
|
||||
/// global filters write the reference bounds; others the content grown by
|
||||
/// the halo (blurs spread into transparent areas). Clipped to the
|
||||
/// selection's bounds when there is one.
|
||||
/// global filters and renders that ignore the layer's pixels (Fibers) write the reference
|
||||
/// bounds; others the content grown by the halo (blurs spread into transparent areas).
|
||||
/// Clipped to the selection's bounds when there is one.
|
||||
pub fn output_area(params: &FilterParams, content: Rect, bounds: Rect, selection_bounds: Option<Rect>) -> Rect {
|
||||
let mut area = match params.halo_for(bounds) {
|
||||
Halo::Bounds => bounds,
|
||||
Halo::Radius(_) if params.renders_from_nothing() => bounds,
|
||||
Halo::Radius(r) => {
|
||||
if content.is_empty() {
|
||||
Rect::EMPTY
|
||||
|
||||
@@ -682,18 +682,23 @@ fn hue_chroma([r, g, b]: [f32; 3]) -> (f32, f32) {
|
||||
|
||||
/// Color Range › Select: Reds, Yellows, Greens, Cyans, Blues or Magentas (`center` = 0, 60,
|
||||
/// 120, 180, 240, 300°). A pixel belongs to a family by how close its hue is (full at the
|
||||
/// family's hue, none 60° away, so an orange is half red, half yellow) times its chroma, so
|
||||
/// neutrals are never selected and muted colours only partly.
|
||||
/// family's hue, none 60° away, so an orange is half red, half yellow) times its chroma
|
||||
/// (max − min), so neutrals are never selected and muted colours only partly. Darker colours
|
||||
/// weigh more, by `2 − max`: measured against Photoshop 2025's presets on 126 colours each for
|
||||
/// Reds, Yellows and Blues (hue ±40°, saturation 5..100 %, brightness 33..100 %), this matches
|
||||
/// its selection to within one level, where chroma alone fell up to 61 levels short (#5243).
|
||||
pub fn hue_range(px: &[[f32; 4]], center: f32) -> Vec<f32> {
|
||||
px.iter()
|
||||
.map(|&[r, g, b, a]| {
|
||||
if a <= 0.0 {
|
||||
return 0.0;
|
||||
}
|
||||
let (h, chroma) = hue_chroma([r, g, b].map(|v| v.clamp(0.0, 1.0)));
|
||||
let rgb = [r, g, b].map(|v| v.clamp(0.0, 1.0));
|
||||
let (h, chroma) = hue_chroma(rgb);
|
||||
let max = rgb[0].max(rgb[1]).max(rgb[2]);
|
||||
let dh = (h - center).rem_euclid(360.0);
|
||||
let dh = dh.min(360.0 - dh);
|
||||
((1.0 - dh / 60.0).clamp(0.0, 1.0) * chroma).clamp(0.0, 1.0)
|
||||
((1.0 - dh / 60.0).clamp(0.0, 1.0) * chroma * (2.0 - max)).clamp(0.0, 1.0)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -1180,6 +1185,17 @@ mod tests {
|
||||
assert!((hue_range(&[[1.0, 0.0, 0.5, 1.0]], 300.0)[0] - 0.5).abs() < 1e-5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hue_families_weigh_dark_colours_like_photoshop() {
|
||||
// Photoshop 2025's Blues on an 8-bit sRGB document (selection levels 0..255, #5243): the
|
||||
// muted navy #3d3f54, a dark blue (0, 0, 84) and a mid blue (61, 61, 153).
|
||||
let c = |r: u8, g: u8, b: u8| [f32::from(r) / 255.0, f32::from(g) / 255.0, f32::from(b) / 255.0, 1.0];
|
||||
let blues = hue_range(&[c(0x3d, 0x3f, 0x54), c(0, 0, 84), c(61, 61, 153)], 240.0);
|
||||
for (got, want) in blues.iter().zip([35.0, 140.0, 129.0]) {
|
||||
assert!((got * 255.0 - want).abs() <= 1.0, "{} vs Photoshop {want}", got * 255.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tonal_ranges() {
|
||||
let g = |v: f32| [v / 255.0, v / 255.0, v / 255.0, 1.0];
|
||||
|
||||
@@ -446,6 +446,10 @@ fn halos_and_output_area() {
|
||||
assert_eq!(output_area(&FilterParams::Twirl { angle: 1.0 }, content, R, None), R);
|
||||
assert_eq!(output_area(&FilterParams::BoxBlur { radius: 1.0 }, content, R, Some(Rect::new(0, 0, 12, 12))), Rect::new(8, 8, 12, 12));
|
||||
assert!(output_area(&FilterParams::Invert, Rect::EMPTY, R, None).is_empty());
|
||||
// Fibers renders without reading the layer: an empty layer still fills the bounds (#5241).
|
||||
let fibers = FilterParams::Fibers { variance: 16.0, strength: 4.0, seed: 0, foreground: [0.0; 4], background: [1.0; 4] };
|
||||
assert_eq!(output_area(&fibers, Rect::EMPTY, R, None), R);
|
||||
assert_eq!(output_area(&fibers, content, R, Some(Rect::new(0, 0, 12, 12))), Rect::new(0, 0, 12, 12));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -166,7 +166,7 @@ async fn agent_completes_ten_scripted_tasks() {
|
||||
let outside = pixel(&c, 1, 1).await;
|
||||
assert!(inside[0] > 0.99 && inside[1] < 0.01, "task 5: centre is red {inside:?}");
|
||||
assert!(outside[0] < 0.1, "task 5: corner shows the photo {outside:?}");
|
||||
run(&c, "select.deselect", json!({})).await;
|
||||
assert_eq!(inspect(&c).await["hasSelection"], false, "task 5: the selection became the mask");
|
||||
|
||||
// 6. Save a selection to a channel and load it back.
|
||||
run(&c, "select.rect", json!({"x": 4, "y": 6, "width": 20, "height": 10})).await;
|
||||
@@ -413,7 +413,7 @@ async fn agent_completes_ten_more_scripted_tasks() {
|
||||
assert_eq!(top_layer(&doc)["hasMask"], true, "task 17");
|
||||
let boundary = pixel(&c, 20, 40).await;
|
||||
assert!(boundary[3] > 0.05 && boundary[3] < 0.95, "task 17: the feathered edge keeps partial alpha {boundary:?}");
|
||||
run(&c, "select.deselect", json!({})).await;
|
||||
assert_eq!(doc["hasSelection"], false, "task 17: the selection became the mask");
|
||||
|
||||
// 18. Expand a selection and read its bounds back.
|
||||
run(&c, "select.rect", json!({"x": 20, "y": 20, "width": 20, "height": 20})).await;
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
//! Interior effects are painted relative to the layer's shape and then take the shape's alpha
|
||||
//! (an overlay recolours a half-transparent edge without adding coverage). The outside parts
|
||||
//! of strokes blend onto the backdrop with their own modes, an upper stroke covering the
|
||||
//! lower ones. Drop shadows are knocked out only through see-through fill.
|
||||
//! lower ones. Drop shadows are knocked out through see-through fill, and beneath the whole shape
|
||||
//! when the layer's mode lets what's under it show through (see [`shadow_see_through`]).
|
||||
//!
|
||||
//! Shapes come from the layer's alpha (after its mask). A stroke's outer edge, and precise glows /
|
||||
//! chiselled bevels, use an exact Euclidean transform: a 5 × 5 chamfer's level sets are polygons,
|
||||
@@ -1850,6 +1851,16 @@ fn knock_out_exterior(map: &mut Map, shape: &Map, fill_opacity: f32) {
|
||||
}
|
||||
}
|
||||
|
||||
/// How far the layer lets a knocked-out drop shadow show beneath its own shape (Layer Knocks Out
|
||||
/// Drop Shadow), 0 = covered, 1 = knocked out wholly. In a normal mode an opaque layer covers the
|
||||
/// shadow anyway, so only see-through fill knocks it out (and anti-aliased edges are not
|
||||
/// attenuated twice). In any other mode the layer blends with what's beneath it, shadow and all:
|
||||
/// an Exclusion or Difference layer would invert it, Multiply darken by it, Screen show it as
|
||||
/// grey. Photoshop keeps it out from under the shape, so here it's knocked out wholly.
|
||||
pub fn shadow_see_through(layer: &Layer) -> f32 {
|
||||
if matches!(layer.blend, BlendMode::Normal | BlendMode::Dissolve | BlendMode::PassThrough) { 1.0 - layer.fill_opacity.clamp(0.0, 1.0) } else { 1.0 }
|
||||
}
|
||||
|
||||
/// Blend Interior Effects as Group off (Photoshop's default): the layer's mode applies to its
|
||||
/// own pixels only, and the interior effects paint over the blended result. The layer is merged
|
||||
/// into the backdrop before they paint, so an Overlay colour overlay on a black Color-mode layer
|
||||
@@ -1916,10 +1927,10 @@ pub(crate) fn composite_with_effects_prepared(
|
||||
if let Effect::DropShadow(s) = e {
|
||||
let mut m = fx(i, 0);
|
||||
if s.knocks_out {
|
||||
// The layer hides the shadow beneath it only where its fill is see-through: at
|
||||
// 100 % fill the layer covers it anyway (and anti-aliased edges are not
|
||||
// attenuated twice), at 0 % the shape shows the bare backdrop.
|
||||
knock_out_exterior(&mut m, &shape, layer.fill_opacity);
|
||||
// The layer hides the shadow beneath it where its fill is see-through (at 100 %
|
||||
// fill in a normal mode it covers it anyway; at 0 % the shape shows the bare
|
||||
// backdrop), and wholly in a mode that blends with it ([`shadow_see_through`]).
|
||||
knock_out_exterior(&mut m, &shape, 1.0 - shadow_see_through(layer));
|
||||
}
|
||||
paint_color(&mut work, &m, rgb(&s.color), s.common.blend, s.common.opacity);
|
||||
}
|
||||
|
||||
@@ -1473,6 +1473,36 @@ fn shadow_knockout_needs_see_through_fill() {
|
||||
assert!(close4(on, px(&base, 10, 20)), "{on:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shadow_knockout_beneath_a_layer_in_a_blending_mode() {
|
||||
// Layer Knocks Out Drop Shadow keeps the shadow out from under the layer's shape. In Normal
|
||||
// mode an opaque layer covers it anyway; in a mode that blends with what's beneath, the shadow
|
||||
// would show through: under a white Exclusion square on white, it read as white (white over
|
||||
// the black shadow) instead of black (white over white), so a logo's Exclusion bar with a
|
||||
// drop shadow came out blank. A red Multiply square came out black instead of red.
|
||||
for (blend, colour, inside, depth) in [
|
||||
(photocraft_color::BlendMode::Exclusion, [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0]),
|
||||
(photocraft_color::BlendMode::Multiply, [1.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0]),
|
||||
]
|
||||
.into_iter()
|
||||
.flat_map(|c| SampleType::ALL.map(|depth| (c, depth)))
|
||||
.map(|((b, c, i), depth)| (b, c, i, depth))
|
||||
{
|
||||
let mut d = Document::new("t", Size::new(40, 40), ColorMode::Rgb, depth);
|
||||
d.layers.push(solid_layer("bg", Rect::new(0, 0, 40, 40), [1.0; 4]));
|
||||
let mut l = solid_layer("sq", Rect::new(10, 10, 30, 30), colour);
|
||||
l.blend = blend;
|
||||
l.effects.items = vec![Effect::DropShadow(shadow(0.0, 90.0))];
|
||||
d.layers.push(l);
|
||||
assert!(close4(px(&d, 20, 20), inside), "{blend:?} {depth:?}: {:?}", px(&d, 20, 20));
|
||||
// Not knocked out, the shadow shows through the blend, as in Photoshop with the box unticked.
|
||||
if let Effect::DropShadow(s) = &mut d.layers[1].effects.items[0] {
|
||||
s.knocks_out = false;
|
||||
}
|
||||
assert!(!close4(px(&d, 20, 20), inside), "{blend:?} {depth:?} without knockout: {:?}", px(&d, 20, 20));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linked_pattern_overlay_anchors_at_the_effects_reference_point() {
|
||||
use photocraft_doc::pattern::Pattern;
|
||||
|
||||
@@ -353,7 +353,6 @@ fn invert_with_the_mask_targeted_inverts_the_mask() {
|
||||
let mut s = session(depth, "rgb");
|
||||
s.execute("select.rect", json!({"x": 24, "y": 0, "width": 24, "height": 32})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
let (pixels, off_canvas) = (rgba(&s, 3, 3), mask_at(&s, -500, 3));
|
||||
let steps = s.active().unwrap().history.past_len();
|
||||
s.execute("image.adjustments.invert", json!({"target": "mask"})).unwrap();
|
||||
@@ -372,6 +371,31 @@ fn invert_with_the_mask_targeted_inverts_the_mask() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Photoshop: a mask made from the selection (Reveal Selection, the Layers panel's mask button)
|
||||
/// takes the selection with it, as Hide Selection does. So ⌘I on the new mask right away inverts
|
||||
/// all of it; with the selection kept it inverted only the inside, leaving the mask all black.
|
||||
/// Undo brings the selection back with the mask gone, in one step.
|
||||
#[test]
|
||||
fn reveal_selection_drops_the_selection_so_invert_flips_the_whole_mask() {
|
||||
for depth in DEPTHS {
|
||||
let mut s = session(depth, "rgb");
|
||||
s.execute("select.rect", json!({"x": 24, "y": 0, "width": 24, "height": 32})).unwrap();
|
||||
let selection = s.active().unwrap().doc.selection.clone();
|
||||
let steps = s.active().unwrap().history.past_len();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
assert!(s.active().unwrap().doc.selection.is_none(), "depth {depth}: the selection became the mask");
|
||||
assert_eq!(s.active().unwrap().history.past_len(), steps + 1, "one step");
|
||||
assert_eq!((mask_at(&s, 3, 3), mask_at(&s, 30, 3)), (0.0, 1.0));
|
||||
s.execute("image.adjustments.invert", json!({"target": "mask"})).unwrap();
|
||||
assert_eq!((mask_at(&s, 3, 3), mask_at(&s, 30, 3)), (1.0, 0.0), "depth {depth}: inside and outside both flip");
|
||||
s.undo();
|
||||
s.undo();
|
||||
let st = s.active().unwrap();
|
||||
assert_eq!(st.doc.selection, selection, "undo restores the selection");
|
||||
assert!(st.doc.layer(st.active_layer.unwrap()).unwrap().mask.is_none(), "and removes the mask");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Image › Adjustments as smart filters (FILE-215-4) ----------
|
||||
|
||||
/// A painted pixel layer converted to a smart object, over the painted Background.
|
||||
@@ -492,7 +516,6 @@ fn a_targeted_mask_enables_editing_it_on_any_layer() {
|
||||
s.execute("layer.delete", json!({})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 24, "y": 0, "width": 24, "height": 32})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
let pixels = rgba(&s, 23, 3);
|
||||
s.execute("filter.blur.gaussianBlur", json!({"radius": 3, "target": "mask"})).unwrap();
|
||||
assert!(mask_at(&s, 23, 3) > 0.0 && mask_at(&s, 23, 3) < 1.0, "the mask's edge is blurred");
|
||||
|
||||
@@ -381,7 +381,7 @@ mod tests {
|
||||
let m = r["aligned"][0]["matrix"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect::<Vec<_>>();
|
||||
assert!((m[2] + 6.0).abs() < 1.0 && (m[5] + 5.0).abs() < 1.0, "{r}");
|
||||
assert!(s.execute("edit.autoAlignLayers", json!({"projection": "sideways"})).is_err());
|
||||
assert!(s.execute("edit.autoAlignLayers", json!({"reference": 9999})).is_err());
|
||||
assert!(s.execute("edit.autoAlignLayers", json!({"reference": u64::MAX})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -50,7 +50,7 @@ fn browse_runs_a_script_file() {
|
||||
assert_eq!((d.size.width, d.size.height), (20, 30));
|
||||
assert!(s.execute("file.scripts.browse", json!({"script": "no.such.command"})).is_err());
|
||||
// A failing step stops the script and is reported.
|
||||
let r = s.execute("file.scripts.browse", json!({"steps": [["layer.delete", {"layer": 999_999}], ["image.imageRotation.90cw", {}]]})).unwrap();
|
||||
let r = s.execute("file.scripts.browse", json!({"steps": [["layer.delete", {"layer": u64::MAX}], ["image.imageRotation.90cw", {}]]})).unwrap();
|
||||
assert_eq!(r["results"].as_array().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ fn a_failed_step_inside_a_called_action_fails_scripts_and_batch() {
|
||||
});
|
||||
s.actions.list.push(Action {
|
||||
name: "Bad".into(),
|
||||
steps: vec![("layer.delete".into(), json!({"layer": 999_999}))],
|
||||
steps: vec![("layer.delete".into(), json!({"layer": u64::MAX}))],
|
||||
disabled: Default::default(),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@@ -144,6 +144,32 @@ mod tests {
|
||||
(s, [bg, a, b])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opacity_fill_or_a_blend_mode_turn_the_background_into_a_layer() {
|
||||
// Like Photoshop: the Background takes none of them, so it becomes "Layer 0" first.
|
||||
for (key, value) in [("opacity", json!(0.5)), ("fill", json!(0.5)), ("blend", json!("Multiply"))] {
|
||||
let (mut s, [bg, ..]) = with_background();
|
||||
s.execute("layer.setProps", json!({"layer": bg.0, key: value})).unwrap();
|
||||
let l = doc(&s).layer(bg).unwrap();
|
||||
assert!(!doc(&s).is_background(bg) && l.name == "Layer 0", "{key}");
|
||||
assert!(l.opacity < 1.0 || l.fill_opacity < 1.0 || l.blend == photocraft_color::BlendMode::Multiply, "{key}: applied");
|
||||
}
|
||||
// Values that leave its look alone keep it the Background.
|
||||
let (mut s, [bg, ..]) = with_background();
|
||||
s.execute("layer.setProps", json!({"layer": bg.0, "opacity": 1.0, "fill": 1.0, "blend": "Normal", "visible": false})).unwrap();
|
||||
assert!(doc(&s).is_background(bg));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_and_mask_output_to_a_layer_mask_turns_the_background_into_a_layer() {
|
||||
let (mut s, [bg, ..]) = with_background();
|
||||
s.execute("layer.select", json!({"layer": bg.0})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 2, "y": 2, "width": 6, "height": 6})).unwrap();
|
||||
s.execute("select.refineEdge", json!({"output": "layerMask"})).unwrap();
|
||||
let l = doc(&s).layer(bg).unwrap();
|
||||
assert!(l.mask.is_some() && !doc(&s).is_background(bg) && l.name == "Layer 0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn makes_the_layer_the_background_at_the_bottom() {
|
||||
for depth in [8, 16, 32] {
|
||||
@@ -207,7 +233,7 @@ mod tests {
|
||||
assert!(s.execute(CMD, json!({"layer": bg.0})).is_err());
|
||||
// Bad params.
|
||||
let (mut s, [_, a, _]) = session(8);
|
||||
for p in [json!({"layer": "A"}), json!({"layer": -1}), json!({"layer": 1.5}), json!({"layer": 99999}), json!({"layer": [a.0]})] {
|
||||
for p in [json!({"layer": "A"}), json!({"layer": -1}), json!({"layer": 1.5}), json!({"layer": u64::MAX}), json!({"layer": [a.0]})] {
|
||||
assert!(s.execute(CMD, p.clone()).is_err(), "{p}");
|
||||
}
|
||||
assert!(doc(&s).background().is_none());
|
||||
|
||||
@@ -59,15 +59,16 @@ pub(crate) fn copy(s: &mut Session) -> Result<Option<Value>> {
|
||||
return Err(EngineError::Other("Could not copy: the selected area is empty".into()));
|
||||
}
|
||||
let fmt = PixelFormat::new(ColorMode::Grayscale, doc.pixel_format().sample, true);
|
||||
let values = src.read_region(area);
|
||||
let cover = sel.map(|m| (m.read_region(area), m.format().channels().max(1)));
|
||||
let mut px = Vec::with_capacity(values.len() / n * 2);
|
||||
let values = crate::allocation::read_region(src, area, "copying a channel")?;
|
||||
let cover = sel.map(|m| crate::allocation::read_region(m, area, "copying a channel selection").map(|v| (v, m.format().channels().max(1)))).transpose()?;
|
||||
let len = (values.len() / n).checked_mul(2).ok_or_else(|| EngineError::Other("the channel is too large to copy".into()))?;
|
||||
let mut px = crate::allocation::capacity(len, "copying a channel")?;
|
||||
for (i, p) in values.chunks_exact(n).enumerate() {
|
||||
px.push(p.get(k).copied().unwrap_or(0.0));
|
||||
px.push(cover.as_ref().map_or(1.0, |(m, mk)| m.get(i * mk).copied().unwrap_or(0.0)));
|
||||
}
|
||||
let mut surface = Surface::new(fmt);
|
||||
surface.write_region(area, &px);
|
||||
surface.try_write_region(area, &px)?;
|
||||
surface.prune();
|
||||
let bounds = surface.content_bounds();
|
||||
if bounds.is_empty() {
|
||||
|
||||
@@ -163,3 +163,22 @@ fn clearing_a_channel_reports_allocation_failure_without_editing() {
|
||||
assert_eq!(s.active().unwrap().history.entries(), history);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn channel_copy_allocation_failure_keeps_clipboard_and_document() {
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = session(depth);
|
||||
s.execute("edit.copy", json!({})).unwrap();
|
||||
s.execute("channel.target", json!({"channel": "red"})).unwrap();
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
let clip = s.clipboard.as_ref().unwrap().surface.clone();
|
||||
let history = s.active().unwrap().history.entries();
|
||||
crate::allocation::fail_next_for_test();
|
||||
let result = copy(&mut s);
|
||||
let _ = crate::allocation::capacity::<u8>(0, "reset failpoint");
|
||||
assert!(result.is_err());
|
||||
assert_eq!(*s.active().unwrap().doc, *before);
|
||||
assert_eq!(s.active().unwrap().history.entries(), history);
|
||||
assert_eq!(s.clipboard.as_ref().unwrap().surface, clip);
|
||||
}
|
||||
}
|
||||
@@ -681,6 +681,16 @@ fn build() -> Vec<CommandSpec> {
|
||||
has_layer,
|
||||
|s, p| {
|
||||
let id = layer_param(s, p)?;
|
||||
// Opacity and Fill are fractions here, while the Layer Style commands take
|
||||
// percentages: a value outside 0..1 is refused, never clamped to 100 % (#5242).
|
||||
let unit = |key: &str| -> Result<Option<f32>> {
|
||||
let Some(v) = p.get(key) else { return Ok(None) };
|
||||
match v.as_f64() {
|
||||
Some(x) if (0.0..=1.0).contains(&x) => Ok(Some(x as f32)),
|
||||
_ => Err(bad("layer.setProps", format!("{key} must be a number in 0..1 (1 = 100 %), got {v}"))),
|
||||
}
|
||||
};
|
||||
let (opacity, fill) = (unit("opacity")?, unit("fill")?);
|
||||
let only_visibility =
|
||||
p.as_object().is_some_and(|o| o.contains_key("visible") && o.keys().all(|k| matches!(k.as_str(), "layer" | "visible" | "coalesce")));
|
||||
let label = if only_visibility { "Layer Visibility" } else { "Layer Properties" };
|
||||
@@ -688,6 +698,13 @@ fn build() -> Vec<CommandSpec> {
|
||||
// Clipping and channel changes reach the layers around it: recomposite everything.
|
||||
let local = p.get("clipped").is_none() && p.get("channels").is_none();
|
||||
s.edit(label, |doc, _| {
|
||||
// The Background has no opacity, fill or blend mode: like Photoshop, setting
|
||||
// one that changes its look turns it into a normal layer ("Layer 0") first.
|
||||
let num = |k: &str| p.get(k).and_then(Value::as_f64).is_some_and(|v| v < 1.0);
|
||||
let blends = p.get("blend").and_then(Value::as_str).and_then(blend_from_str).is_some_and(|b| b != photocraft_color::BlendMode::Normal);
|
||||
if num("opacity") || num("fill") || blends {
|
||||
crate::extra_cmds::background_to_layer(doc, id);
|
||||
}
|
||||
let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?;
|
||||
if let Some(v) = p.get("name").and_then(Value::as_str) {
|
||||
l.name = v.to_string();
|
||||
@@ -695,11 +712,11 @@ fn build() -> Vec<CommandSpec> {
|
||||
if let Some(v) = p.get("visible").and_then(Value::as_bool) {
|
||||
l.visible = v;
|
||||
}
|
||||
if let Some(v) = p.get("opacity").and_then(Value::as_f64) {
|
||||
l.opacity = (v as f32).clamp(0.0, 1.0);
|
||||
if let Some(v) = opacity {
|
||||
l.opacity = v;
|
||||
}
|
||||
if let Some(v) = p.get("fill").and_then(Value::as_f64) {
|
||||
l.fill_opacity = (v as f32).clamp(0.0, 1.0);
|
||||
if let Some(v) = fill {
|
||||
l.fill_opacity = v;
|
||||
}
|
||||
if let Some(v) = p.get("blend").and_then(Value::as_str) {
|
||||
l.blend = blend_from_str(v).ok_or_else(|| bad("layer.setProps", format!("unknown blend mode `{v}`")))?;
|
||||
@@ -788,7 +805,10 @@ fn build() -> Vec<CommandSpec> {
|
||||
|s, p| {
|
||||
let sel = s.active().and_then(|d| d.doc.selection.clone()).ok_or(EngineError::Other("no selection".into()))?;
|
||||
let mask = LayerMask { surface: sel, ..LayerMask::reveal_all() };
|
||||
set_mask(s, p, "Add Layer Mask", Some(mask))
|
||||
// The selection becomes the mask, so Photoshop drops it (as Hide Selection does): a
|
||||
// following Invert (⌘I) on the targeted mask then inverts all of it, not just the
|
||||
// part inside the old selection. Same undo step as the mask.
|
||||
set_mask_and_deselect(s, p, "Add Layer Mask", mask)
|
||||
}
|
||||
),
|
||||
cmd!("layer.layerMask.delete", "Delete", ["Layer", "Layer Mask"], None, r##"{"layer":id?}"##, has_layer, |s, p| set_mask(
|
||||
@@ -1427,6 +1447,15 @@ fn arrange(s: &mut Session, p: &Value, delta: i32) -> Result<Value> {
|
||||
/// Add (`Some`) or remove (`None`) a layer mask. Adding acts on every selected layer that can take
|
||||
/// one ([`crate::layer_multi_cmds::mask_targets`]), in one history step.
|
||||
fn set_mask(s: &mut Session, p: &Value, label: &str, mask: Option<LayerMask>) -> Result<Value> {
|
||||
set_mask_with(s, p, label, mask, false)
|
||||
}
|
||||
|
||||
/// [`set_mask`] that also drops the selection the mask was made from, in the same history step.
|
||||
fn set_mask_and_deselect(s: &mut Session, p: &Value, label: &str, mask: LayerMask) -> Result<Value> {
|
||||
set_mask_with(s, p, label, Some(mask), true)
|
||||
}
|
||||
|
||||
fn set_mask_with(s: &mut Session, p: &Value, label: &str, mask: Option<LayerMask>, deselect: bool) -> Result<Value> {
|
||||
let ids = if mask.is_some() { crate::layer_multi_cmds::mask_targets(s, p)? } else { vec![layer_param(s, p)?] };
|
||||
s.edit(label, |doc, _| {
|
||||
let mask = mask.clone().map(|mask| mask_at_depth(mask, doc.depth)).transpose()?;
|
||||
@@ -1436,6 +1465,9 @@ fn set_mask(s: &mut Session, p: &Value, label: &str, mask: Option<LayerMask>) ->
|
||||
}
|
||||
doc.layer_mut(*id).ok_or(EngineError::NoLayer(*id))?.mask = mask.clone();
|
||||
}
|
||||
if deselect {
|
||||
doc.selection = None;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(Value::Null)
|
||||
@@ -1547,3 +1579,30 @@ mod registry_tests {
|
||||
assert_eq!(registry.specs.len(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod set_props_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn opacity_and_fill_outside_zero_to_one_are_refused_not_clamped() {
|
||||
// #5242: `55` (a percentage, as the Layer Style commands take) used to become 100 %.
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
s.execute("layer.setProps", json!({"opacity": 0.55, "fill": 0.4})).unwrap();
|
||||
let layer = |s: &Session| {
|
||||
let d = s.active().unwrap();
|
||||
let l = d.doc.layer(d.active_layer.unwrap()).unwrap();
|
||||
(l.opacity, l.fill_opacity)
|
||||
};
|
||||
assert_eq!(layer(&s), (0.55, 0.4));
|
||||
for bad in [json!({"opacity": 55}), json!({"opacity": -0.1}), json!({"fill": 1.5}), json!({"opacity": "50%"}), json!({"opacity": 0.5, "fill": 40})] {
|
||||
let e = s.execute("layer.setProps", bad.clone()).unwrap_err().to_string();
|
||||
assert!(e.contains("0..1"), "{bad}: {e}");
|
||||
assert_eq!(layer(&s), (0.55, 0.4), "{bad} left the layer alone");
|
||||
}
|
||||
s.execute("layer.setProps", json!({"opacity": 0, "fill": 1})).unwrap();
|
||||
assert_eq!(layer(&s), (0.0, 1.0));
|
||||
}
|
||||
}
|
||||
@@ -254,7 +254,7 @@ mod tests {
|
||||
|
||||
let (mut s, _) = disc(8);
|
||||
let before = s.active().unwrap().revision;
|
||||
assert!(s.execute(CMD, json!({"layer": 999_999})).is_err());
|
||||
assert!(s.execute(CMD, json!({"layer": u64::MAX})).is_err());
|
||||
// A `layer` string names a layer; one that isn't there is an error, not the active layer.
|
||||
assert!(s.execute(CMD, json!({"layer": "x"})).is_err());
|
||||
assert_eq!(s.active().unwrap().revision, before);
|
||||
|
||||
@@ -495,9 +495,12 @@ fn new_from_clipboard(s: &mut Session) -> Result<Value> {
|
||||
if w == 0 || h == 0 {
|
||||
return Err(EngineError::Other("the clipboard image has no size".into()));
|
||||
}
|
||||
let (Some(dx), Some(dy)) = (b.x0.checked_neg(), b.y0.checked_neg()) else {
|
||||
return Err(EngineError::Other("the clipboard origin is outside the coordinate range for a new document".into()));
|
||||
};
|
||||
let fmt = clip.surface.format();
|
||||
let target = PixelFormat::new(fmt.mode, fmt.sample, true);
|
||||
let moved = if b.x0 == 0 && b.y0 == 0 { clip.surface } else { photocraft_algo::resample::translate_surface(&clip.surface, -b.x0, -b.y0) };
|
||||
let moved = if dx == 0 && dy == 0 { clip.surface } else { photocraft_algo::resample::translate_surface(&clip.surface, dx, dy) };
|
||||
let mut doc = Document::new("Untitled", photocraft_geom::Size::new(w, h), fmt.mode, fmt.sample);
|
||||
if let Some(r) = clip.resolution.filter(|r| r.is_finite() && *r > 0.0) {
|
||||
doc.resolution_dpi = r;
|
||||
@@ -1044,6 +1047,19 @@ mod tests {
|
||||
s
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_clipboard_document_rejects_an_unrepresentable_origin() {
|
||||
let mut s = Session::new();
|
||||
let mut surface = Surface::new(PixelFormat::RGBA8);
|
||||
surface.write_pixel(i32::MIN, 0, &[1.0, 0.0, 0.0, 1.0]);
|
||||
s.clipboard = Some(Clip { surface, bounds: Rect::from_xywh(i32::MIN, 0, 1, 1), layers: None, resolution: None });
|
||||
let result = new_from_clipboard(&mut s);
|
||||
assert!(result.unwrap_err().to_string().contains("clipboard origin"));
|
||||
assert!(s.execute("file.newFromClipboard", json!({})).is_err());
|
||||
assert!(s.documents().is_empty());
|
||||
assert_eq!(s.clipboard.as_ref().unwrap().surface.rgba(i32::MIN, 0), [1.0, 0.0, 0.0, 1.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn injected_clear_buffer_failure_leaves_the_document_unchanged() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -1549,7 +1549,7 @@ mod tests {
|
||||
// Layer 1 is already the only visible layer: ⌥-clicking it shows everything.
|
||||
assert_eq!(s.execute("layer.showOnly", json!({})).unwrap()["shownAlone"], false);
|
||||
assert!(doc(&s).layers.iter().all(|l| l.visible));
|
||||
assert!(s.execute("layer.showOnly", json!({"layer": 9999})).is_err());
|
||||
assert!(s.execute("layer.showOnly", json!({"layer": u64::MAX})).is_err());
|
||||
assert!(Session::new().execute("layer.showOnly", json!({})).is_err());
|
||||
}
|
||||
|
||||
@@ -1624,7 +1624,7 @@ mod tests {
|
||||
let bg_locks = doc(&s).layer(bg).unwrap().locks;
|
||||
assert!(s.execute("layer.toggleLockTransparency", json!({"layer": bg.0})).is_err());
|
||||
assert_eq!(doc(&s).layer(bg).unwrap().locks, bg_locks, "the Background is left alone");
|
||||
assert!(s.execute("layer.toggleLockTransparency", json!({"layer": 999_999})).is_err());
|
||||
assert!(s.execute("layer.toggleLockTransparency", json!({"layer": u64::MAX})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -586,7 +586,6 @@ fn flatten_all_layer_effects_and_masks() {
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 20, "height": 40})).unwrap();
|
||||
s.execute("select.inverse", json!({})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
assert!(composite(&s, 15, 15)[1] > 0.99 && composite(&s, 15, 15)[0] > 0.99, "white shows through the mask");
|
||||
let r = s.execute("file.scripts.flattenAllMasks", json!({})).unwrap();
|
||||
assert_eq!(r["flattened"], 1);
|
||||
@@ -633,7 +632,6 @@ fn flatten_all_layer_effects_keeps_masks() {
|
||||
.unwrap();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 20, "height": 40})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
// Layer 2: a red square at the bottom-right with the same overlay and a *disabled* mask.
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 30, "y": 30, "width": 8, "height": 8})).unwrap();
|
||||
@@ -652,7 +650,6 @@ fn flatten_all_layer_effects_keeps_masks() {
|
||||
.unwrap();
|
||||
s.execute("select.rect", json!({"x": 34, "y": 34, "width": 2, "height": 2})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.edit("disable", |doc, _| {
|
||||
if let Some(m) = doc.layer_mut(id2).and_then(|l| l.mask.as_mut()) {
|
||||
m.enabled = false;
|
||||
|
||||
@@ -264,7 +264,7 @@ mod tests {
|
||||
for id in IDS {
|
||||
assert!(s.execute(id, json!([1, 2])).is_err(), "{id}");
|
||||
assert!(s.execute(id, json!("x")).is_err(), "{id}");
|
||||
assert!(s.execute(id, json!({"layer": 99_999})).is_err(), "{id}");
|
||||
assert!(s.execute(id, json!({"layer": u64::MAX})).is_err(), "{id}");
|
||||
assert!(s.execute(id, json!({"target": {"channel": 42}})).is_err(), "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +460,6 @@ mod tests {
|
||||
if reveal_selection {
|
||||
s.execute("select.all", json!({})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
} else {
|
||||
s.execute("layer.layerMask.revealAll", json!({})).unwrap();
|
||||
}
|
||||
|
||||
@@ -164,6 +164,27 @@ fn colour_filters_use_and_record_tool_colours() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fibers_fill_an_empty_layer() {
|
||||
// #5241: Fibers renders from the colours, not the layer's pixels, so an empty layer fills
|
||||
// like in Photoshop (and can be transformed afterwards).
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 48, "height": 32})).unwrap();
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
s.execute("filter.render.fibers", json!({"seed": 3})).unwrap();
|
||||
let px = pixels(&s);
|
||||
assert!(px.as_chunks::<4>().0.iter().all(|p| p[3] == 1.0), "every pixel is rendered opaque");
|
||||
s.execute("edit.transform.flipHorizontal", json!({})).unwrap();
|
||||
|
||||
// With a selection only the selection fills.
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 4, "y": 4, "width": 10, "height": 6})).unwrap();
|
||||
s.execute("filter.render.fibers", json!({"seed": 3})).unwrap();
|
||||
let d = s.active().unwrap();
|
||||
let surf = d.doc.layer(d.active_layer.unwrap()).unwrap().surface().unwrap();
|
||||
assert_eq!(surf.content_bounds(), Rect::new(4, 4, 14, 10));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn displace_reads_another_document() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -118,7 +118,7 @@ mod tests {
|
||||
let bg = s.active().unwrap().doc.layers[0].id.0;
|
||||
for p in [
|
||||
json!({"layer": bg}),
|
||||
json!({"layer": 9999}),
|
||||
json!({"layer": u64::MAX}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": -1}),
|
||||
json!({"expanded": "yes", "all": true}),
|
||||
|
||||
@@ -161,7 +161,7 @@ mod tests {
|
||||
let before = state(&s, a);
|
||||
for p in [
|
||||
json!({"layer": bg}),
|
||||
json!({"layer": 9999}),
|
||||
json!({"layer": u64::MAX}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": -1}),
|
||||
json!({"layer": a, "index": 2}),
|
||||
|
||||
@@ -273,7 +273,7 @@ fn commands_fail_gracefully() {
|
||||
// A zero-length drag still makes a valid gradient.
|
||||
s.execute(CREATE, json!({"from": [3, 3], "to": [3, 3]})).unwrap();
|
||||
for p in [
|
||||
json!({"layer": 999_999}),
|
||||
json!({"layer": u64::MAX}),
|
||||
json!({"from": [0]}),
|
||||
json!({"to": [1e30, 0]}),
|
||||
json!({"angle": "x"}),
|
||||
|
||||
@@ -142,7 +142,7 @@ mod tests {
|
||||
let bg = s.active().unwrap().doc.layers[0].id.0;
|
||||
for p in [
|
||||
json!({"layer": bg}),
|
||||
json!({"layer": 9999}),
|
||||
json!({"layer": u64::MAX}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": -1}),
|
||||
json!({"expanded": "yes", "all": true}),
|
||||
|
||||
@@ -130,7 +130,7 @@ fn bad_params_and_states_fail_without_changing_anything() {
|
||||
json!({"document": -1}),
|
||||
json!({"document": "1"}),
|
||||
json!({"document": 1, "source": 9}),
|
||||
json!({"document": 1, "layers": [999_999]}),
|
||||
json!({"document": 1, "layers": [u64::MAX]}),
|
||||
json!({"document": 1, "layers": "all"}),
|
||||
json!({"document": 1, "layers": []}),
|
||||
json!({"document": 1, "at": [1.0]}),
|
||||
@@ -314,7 +314,7 @@ fn duplicate_destinations_that_are_not_new_fail_cleanly() {
|
||||
json!({"document": []}),
|
||||
json!({"document": {}}),
|
||||
json!({"document": "other"}),
|
||||
json!({"document": "new", "layer": 999_999}),
|
||||
json!({"document": "new", "layer": u64::MAX}),
|
||||
] {
|
||||
let before = (doc(&s, 0).clone(), s.documents().len(), s.active_index());
|
||||
let err = s.execute("layer.duplicate", p.clone()).unwrap_err().to_string();
|
||||
|
||||
@@ -588,7 +588,7 @@ fn transfer_effects_moves_or_copies_between_layers() {
|
||||
for bad in [
|
||||
json!({"from": a.0, "to": a.0}),
|
||||
json!({"from": a.0}),
|
||||
json!({"from": a.0, "to": 9999}),
|
||||
json!({"from": a.0, "to": u64::MAX}),
|
||||
json!({"from": a.0, "to": b.0, "effect": 7}),
|
||||
json!({"from": a.0, "to": b.0, "effect": -1}),
|
||||
json!({"from": b.0, "to": a.0}),
|
||||
|
||||
@@ -1625,8 +1625,8 @@ mod tests {
|
||||
let all = doc(&s).bounds();
|
||||
assert!(damage(&s).is_none_or(|r| r.contains_rect(&all)), "{:?}", damage(&s));
|
||||
// Bad params still fail cleanly.
|
||||
assert!(s.execute("layer.setProps", json!({"layer": 999_999, "visible": true})).is_err());
|
||||
assert!(s.execute("layer.translate", json!({"layer": 999_999, "dx": 1})).is_err());
|
||||
assert!(s.execute("layer.setProps", json!({"layer": u64::MAX, "visible": true})).is_err());
|
||||
assert!(s.execute("layer.translate", json!({"layer": u64::MAX, "dx": 1})).is_err());
|
||||
}
|
||||
|
||||
/// #1771: a new empty layer or group changes no pixels, so it (and undoing or redoing it)
|
||||
@@ -1805,7 +1805,7 @@ mod tests {
|
||||
let mut locked = (*before).clone();
|
||||
locked.layer_mut(a).unwrap().locks.position = true;
|
||||
assert!(moved(&locked, &ids, 1, 1).is_err());
|
||||
assert!(moved(&before, &[LayerId(999_999)], 1, 1).is_err());
|
||||
assert!(moved(&before, &[LayerId(u64::MAX)], 1, 1).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1894,7 +1894,7 @@ mod tests {
|
||||
assert_eq!(s.active().unwrap().doc.layer(a).unwrap().name, "x");
|
||||
s.execute("layer.showLayers", json!({"layer": a.0})).unwrap();
|
||||
assert!(s.active().unwrap().doc.layer(a).unwrap().visible);
|
||||
assert!(s.execute("layer.hideLayers", json!({"layer": 999_999})).is_err());
|
||||
assert!(s.execute("layer.hideLayers", json!({"layer": u64::MAX})).is_err());
|
||||
assert!(s.execute("layer.hideLayers", json!({})).is_err());
|
||||
assert!(!s.is_enabled("layer.align.topEdges"));
|
||||
}
|
||||
|
||||
@@ -1206,7 +1206,7 @@ mod tests {
|
||||
let layer = s.active().unwrap().active_layer.unwrap().0;
|
||||
s.execute("layer.layerStyle.clear", json!({"layer": layer, "effect": 0})).unwrap();
|
||||
assert!(matches!(effects(&s)[..], [Effect::ColorOverlay { .. }]));
|
||||
for bad in [json!({"effect": 5}), json!({"effect": -1}), json!({"effect": "x"}), json!({"effect": 0, "layer": 999_999})] {
|
||||
for bad in [json!({"effect": 5}), json!({"effect": -1}), json!({"effect": "x"}), json!({"effect": 0, "layer": u64::MAX})] {
|
||||
assert!(s.execute("layer.layerStyle.clear", bad).is_err());
|
||||
}
|
||||
assert_eq!(effects(&s).len(), 1, "bad params change nothing");
|
||||
|
||||
@@ -10,7 +10,6 @@ fn session() -> (Session, u64, u64) {
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 20, "y": 0, "width": 20, "height": 20})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
let st = s.active_mut().unwrap();
|
||||
st.saved_revision = st.revision;
|
||||
(s, masked, bg)
|
||||
@@ -96,7 +95,7 @@ fn bad_params_and_no_mask_fail_gracefully() {
|
||||
for p in [
|
||||
json!({"layer": bg, "mode": "gray"}),
|
||||
json!({"layer": bg}),
|
||||
json!({"layer": 999_999, "mode": "gray"}),
|
||||
json!({"layer": u64::MAX, "mode": "gray"}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": -1}),
|
||||
json!({"mode": 3}),
|
||||
|
||||
@@ -225,7 +225,7 @@ mod tests {
|
||||
json!([1, 2]),
|
||||
json!({"layer": -1}),
|
||||
json!({"layer": "x"}),
|
||||
json!({"layer": 999_999}),
|
||||
json!({"layer": u64::MAX}),
|
||||
json!({"document": 999_999}),
|
||||
json!({"pattern": "nope"}),
|
||||
json!({"pattern": ""}),
|
||||
|
||||
@@ -1553,7 +1553,8 @@ impl Session {
|
||||
}
|
||||
};
|
||||
interface.insert("appearanceMode".into(), json!(mode));
|
||||
interface.insert(slot.into(), json!(theme.name()));
|
||||
// A partially migrated file may already contain a newer theme selection (#5139).
|
||||
interface.entry(slot).or_insert_with(|| json!(theme.name()));
|
||||
}
|
||||
let color = v.as_object_mut().and_then(|m| m.remove("colorSettings"));
|
||||
let presets = v.as_object_mut().and_then(|m| m.remove("presets"));
|
||||
|
||||
@@ -67,6 +67,17 @@ fn appearance_defaults_and_legacy_theme_migrate() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_theme_migration_preserves_saved_theme_slots() {
|
||||
for (legacy, slot, saved) in [("proMedium", "darkTheme", "solarizedDark"), ("studioLight", "lightTheme", "adwaita")] {
|
||||
let mut interface = json!({"theme": legacy});
|
||||
interface[slot] = json!(saved);
|
||||
let mut session = Session::new();
|
||||
session.load_prefs_json(&json!({"interface": interface}).to_string()).unwrap();
|
||||
assert_eq!(session.prefs_value()["interface"][slot], saved, "explicit {slot} survives migration");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appearance_choices_validate_and_legacy_theme_still_selects() {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -78,7 +78,6 @@ fn fill_opacity_masks_and_layer_opacity_survive_the_bake() {
|
||||
s.execute("layer.setProps", json!({"layer": id, "fill": 0.4, "opacity": 0.7})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 34, "height": 48})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
let square = json!({"subpaths": [{"closed": true, "knots": [[4, 4], [60, 4], [60, 26], [4, 26]]}]});
|
||||
s.execute("layer.vectorMask.add", json!({"layer": id, "path": square})).unwrap();
|
||||
bake_and_check(&mut s, id, depth);
|
||||
@@ -153,7 +152,7 @@ fn disabled_and_bad_params_fail_gracefully() {
|
||||
let (mut s, id) = scene(8);
|
||||
let bg = doc(&s).layers[0].id.0;
|
||||
assert!(s.execute(ID, json!({"layer": bg})).is_err(), "the Background has no effects");
|
||||
assert!(s.execute(ID, json!({"layer": 9999})).is_err(), "no such layer");
|
||||
assert!(s.execute(ID, json!({"layer": u64::MAX})).is_err(), "no such layer");
|
||||
assert!(s.execute(ID, json!({"layer": u64::MAX})).is_err(), "no such layer");
|
||||
assert_eq!(layer(&s, id).effects.items.len(), 5, "a bad call changes nothing");
|
||||
s.execute("layer.layerStyle.hideAllEffects", json!({})).unwrap();
|
||||
|
||||
@@ -993,7 +993,7 @@ fn patch_fails_gracefully() {
|
||||
json!({"offset": [0, -30]}),
|
||||
json!({"offset": [10, 0], "target": "mask"}),
|
||||
json!({"offset": [10, 0], "target": {"channel": 7}}),
|
||||
json!({"offset": [10, 0], "layer": 999}),
|
||||
json!({"offset": [10, 0], "layer": u64::MAX}),
|
||||
] {
|
||||
assert!(s.execute("paint.patch", p.clone()).is_err(), "{p}");
|
||||
}
|
||||
@@ -1269,7 +1269,7 @@ fn content_aware_move_fails_gracefully() {
|
||||
json!({"offset": [0, -30]}),
|
||||
json!({"offset": [10, 0], "target": "mask"}),
|
||||
json!({"offset": [10, 0], "target": {"channel": 7}}),
|
||||
json!({"offset": [10, 0], "layer": 999}),
|
||||
json!({"offset": [10, 0], "layer": u64::MAX}),
|
||||
json!({"offset": [10, 0], "scaleX": 0}),
|
||||
json!({"offset": [10, 0], "scaleY": 0.5}),
|
||||
json!({"offset": [10, 0], "scaleX": 1e9}),
|
||||
@@ -1727,7 +1727,7 @@ fn remove_bad_params_are_errors() {
|
||||
json!({"points": []}),
|
||||
json!({"points": "x"}),
|
||||
json!({"points": [[1, 1]], "size": "big", "closeLoops": "yes", "sampleAllLayers": 3}),
|
||||
json!({"points": [[1, 1]], "layer": 999_999}),
|
||||
json!({"points": [[1, 1]], "layer": u64::MAX}),
|
||||
] {
|
||||
let _ = s.execute("paint.remove", p);
|
||||
}
|
||||
|
||||
@@ -461,7 +461,12 @@ fn modify(s: &mut Session, p: &Value, op: &str) -> Result<Value> {
|
||||
// continue past the canvas. Border has no such option: its band always follows the canvas edge,
|
||||
// or a Select All would border to nothing.
|
||||
let at_bounds = op == "border" || b(p, "applyAtCanvasBounds", false);
|
||||
let (area, m) = current_mask(&s.active().ok_or(EngineError::NoDocument)?.doc);
|
||||
let doc = &s.active().ok_or(EngineError::NoDocument)?.doc;
|
||||
let area = doc.bounds();
|
||||
if area.size().area() > MAX_MODIFY_PIXELS as u64 {
|
||||
return Err(EngineError::BadParams { cmd: format!("select.modify.{op}"), msg: "the selection is too large to modify".into() });
|
||||
}
|
||||
let (_, m) = current_mask(doc);
|
||||
let (w, h) = (area.width() as usize, area.height() as usize);
|
||||
// Feather reaches 3σ = 3 r (σ = r, as in Photoshop); the others reach r. A margin past that
|
||||
// keeps the canvas edge out of reach. A selection clear of the canvas edge needs none: both
|
||||
@@ -765,6 +770,28 @@ mod tests {
|
||||
assert!(err.to_string().contains("detectFaces"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modify_rejects_oversized_canvases_before_reading_the_mask() {
|
||||
let mut s = Session::new();
|
||||
let mut doc = photocraft_doc::Document::new(
|
||||
"large",
|
||||
photocraft_geom::Size::new(300_000, 300_000),
|
||||
photocraft_color::ColorMode::Rgb,
|
||||
photocraft_color::SampleType::U8,
|
||||
);
|
||||
let mut selection = photocraft_raster::Surface::new(photocraft_color::PixelFormat::GRAY8);
|
||||
selection.write_pixel(0, 0, &[1.0]);
|
||||
doc.selection = Some(selection);
|
||||
s.add_document(doc, None);
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
for op in ["expand", "contract", "border", "smooth", "feather"] {
|
||||
let error = s.execute(&format!("select.modify.{op}"), json!({"radius": 1})).unwrap_err();
|
||||
assert!(error.to_string().contains("too large to modify"));
|
||||
assert_eq!(*s.active().unwrap().doc, *before);
|
||||
assert!(!s.active().unwrap().history.can_undo());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_range_replace_is_bounded_by_existing_selection() {
|
||||
for params in [json!({"color": "#ff0000", "fuzziness": 0}), json!({"select": "reds"})] {
|
||||
@@ -850,7 +877,6 @@ mod tests {
|
||||
let mut s = session();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.execute("view.layerMask", json!({"mode": "gray"})).unwrap();
|
||||
s.execute("select.magicWand", json!({"x": 7, "y": 7, "tolerance": 0, "antiAlias": false})).unwrap();
|
||||
assert_eq!(coverage(&s, 2, 2), 1.0, "gray mask view selects the mask");
|
||||
@@ -977,6 +1003,45 @@ mod tests {
|
||||
assert!(lighter > redder + 0.15 && redder > 0.0, "lighter {lighter}, redder {redder}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_range_fuzziness_zero_selects_exact_match_only() {
|
||||
// Sampled Colors at Fuzziness 0 selects only the exact match (TOOL-214-3, #214).
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 50, "height": 10})).unwrap();
|
||||
s.edit("paint", |doc, _| {
|
||||
let bg = doc.layers[0].surface_mut().unwrap();
|
||||
let v = |c: u8| f32::from(c) / 255.0;
|
||||
// Exact target color [200, 140, 120]
|
||||
bg.fill_rect(Rect::new(0, 0, 10, 10), &[v(200), v(140), v(120), 1.0]);
|
||||
// Off by 1 level in red [201, 140, 120]
|
||||
bg.fill_rect(Rect::new(10, 0, 20, 10), &[v(201), v(140), v(120), 1.0]);
|
||||
// Off by 1 level in green [200, 141, 120]
|
||||
bg.fill_rect(Rect::new(20, 0, 30, 10), &[v(200), v(141), v(120), 1.0]);
|
||||
// Off by 2 levels in blue [200, 140, 122] (crosses 8-bit Lab grid threshold)
|
||||
bg.fill_rect(Rect::new(30, 0, 40, 10), &[v(200), v(140), v(122), 1.0]);
|
||||
// Exact target color again at a different position
|
||||
bg.fill_rect(Rect::new(40, 0, 50, 10), &[v(200), v(140), v(120), 1.0]);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// Sampled via eyedropper point at [5, 5] with Fuzziness 0
|
||||
s.execute("select.colorRange", json!({"points": [[5, 5]], "fuzziness": 0})).unwrap();
|
||||
assert_eq!(coverage(&s, 5, 5), 1.0, "sampled pixel itself is fully selected");
|
||||
assert_eq!(coverage(&s, 45, 5), 1.0, "identical color elsewhere on canvas is fully selected");
|
||||
assert_eq!(coverage(&s, 15, 5), 0.0, "1 level off in red is unselected at fuzziness 0");
|
||||
assert_eq!(coverage(&s, 25, 5), 0.0, "1 level off in green is unselected at fuzziness 0");
|
||||
assert_eq!(coverage(&s, 35, 5), 0.0, "1 level off in blue is unselected at fuzziness 0");
|
||||
|
||||
// Sampled via hex color with Fuzziness 0
|
||||
s.execute("select.colorRange", json!({"color": "#c88c78", "fuzziness": 0})).unwrap();
|
||||
assert_eq!(coverage(&s, 5, 5), 1.0, "exact color match from hex is fully selected");
|
||||
assert_eq!(coverage(&s, 45, 5), 1.0, "identical color elsewhere on canvas is fully selected");
|
||||
assert_eq!(coverage(&s, 15, 5), 0.0, "1 level off in red is unselected for hex at fuzziness 0");
|
||||
assert_eq!(coverage(&s, 25, 5), 0.0, "1 level off in green is unselected for hex at fuzziness 0");
|
||||
assert_eq!(coverage(&s, 35, 5), 0.0, "1 level off in blue is unselected for hex at fuzziness 0");
|
||||
}
|
||||
|
||||
/// Red squares (from `session`), a blue square, a black and a mid-grey strip on white.
|
||||
fn session_colours() -> Session {
|
||||
let mut s = session();
|
||||
|
||||
@@ -243,7 +243,7 @@ fn smart_filter_commands_check_an_explicit_layer_target() {
|
||||
assert_eq!(active(&s), curves, "the active layer stays");
|
||||
// A target that isn't a smart object with filters is still refused, and the active layer stays.
|
||||
assert!(matches!(s.execute("layer.smartFilter.setParams", json!({"layer": curves, "params": {}})), Err(EngineError::Disabled(..))));
|
||||
assert!(s.execute("layer.smartFilter.setParams", json!({"layer": 999_999, "params": {}})).is_err());
|
||||
assert!(s.execute("layer.smartFilter.setParams", json!({"layer": u64::MAX, "params": {}})).is_err());
|
||||
assert_eq!(active(&s), curves);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,10 +217,23 @@ impl ObjectFinderCache {
|
||||
}
|
||||
}
|
||||
|
||||
/// Object Selection samples only the active layer by default: when that layer has no pixels in
|
||||
/// `area`, say so instead of quietly finding nothing (#5246; scripts often add an empty layer
|
||||
/// above the photo first).
|
||||
fn check_sampled_pixels(doc: &Document, layer: Option<LayerId>, all_layers: bool, area: Rect) -> Result<()> {
|
||||
let Some(surf) = sampled_target(doc, layer, all_layers).and_then(|id| doc.layer(id)).and_then(Layer::surface) else { return Ok(()) };
|
||||
if surf.content_bounds().intersect(&area).is_empty() {
|
||||
let msg = if surf.content_bounds().is_empty() { "the active layer is empty" } else { "the active layer has no pixels in that area" };
|
||||
return Err(bad("select.object", &format!("{msg}; set \"sampleAllLayers\": true or select a layer with pixels")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `select.object` with `"point"`: the Object Finder's object under the point (cached).
|
||||
fn object_at_point(s: &mut Session, p: &Value, (x, y): (f32, f32)) -> Result<Value> {
|
||||
let all_layers = b(p, "sampleAllLayers", false);
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
check_sampled_pixels(&d.doc, d.active_layer, all_layers, Rect::from_xywh(x.floor() as i32, y.floor() as i32, 1, 1))?;
|
||||
let target = sampled_target(&d.doc, d.active_layer, all_layers);
|
||||
let region = match s.object_finder.lookup(&d.doc, target, x, y) {
|
||||
Some(r) => Some(r),
|
||||
@@ -248,7 +261,10 @@ fn object_selection(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return object_at_point(s, p, pt);
|
||||
}
|
||||
let rect = rect_param(p).ok_or_else(|| bad("select.object", "needs \"rect\": [x, y, w, h] or \"point\": [x, y]"))?;
|
||||
let region = with_sampler(s, b(p, "sampleAllLayers", false), |smp, doc| grabcut::object_select(smp, doc.bounds(), rect, 160_000))?;
|
||||
let all_layers = b(p, "sampleAllLayers", false);
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
check_sampled_pixels(&d.doc, d.active_layer, all_layers, rect)?;
|
||||
let region = with_sampler(s, all_layers, |smp, doc| grabcut::object_select(smp, doc.bounds(), rect, 160_000))?;
|
||||
apply(s, "Object Selection", region.as_ref(), mode(p, "replace"))
|
||||
}
|
||||
|
||||
@@ -417,6 +433,7 @@ fn refine_edge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
s.edit("Select and Mask", |doc, _| {
|
||||
let surface =
|
||||
region.as_ref().map(matting::region_surface).unwrap_or_else(|| photocraft_raster::Surface::new(photocraft_color::PixelFormat::GRAY8));
|
||||
crate::extra_cmds::background_to_layer_for_mask(doc, id);
|
||||
let existing = doc.layer(id).and_then(|l| l.mask.as_ref()).cloned().unwrap_or_else(LayerMask::reveal_all);
|
||||
doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?.mask = Some(LayerMask { surface, ..existing });
|
||||
doc.selection = None;
|
||||
@@ -703,7 +720,7 @@ mod tests {
|
||||
// Any point on the object hits; the background and another target miss.
|
||||
assert!(std::sync::Arc::ptr_eq(&s.object_finder.lookup(&doc, target, 120.0, 90.0).unwrap(), &r));
|
||||
assert!(s.object_finder.lookup(&doc, target, 3.0, 3.0).is_none());
|
||||
assert!(s.object_finder.lookup(&doc, Some(LayerId(9999)), 100.0, 80.0).is_none());
|
||||
assert!(s.object_finder.lookup(&doc, Some(LayerId(u64::MAX)), 100.0, 80.0).is_none());
|
||||
// The click reuses it, and a selection-only edit keeps it.
|
||||
s.execute("select.object", json!({"point": [110, 70]})).unwrap();
|
||||
assert_eq!(s.object_finder.len(), 1);
|
||||
@@ -730,6 +747,26 @@ mod tests {
|
||||
assert!(cov(&s, 100, 80) >= 0.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn object_selection_on_an_empty_active_layer_says_so() {
|
||||
// #5246: an empty layer above the photo used to find nothing without a word.
|
||||
let (mut s, inside) = disc(8);
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
for p in [json!({"rect": [40, 20, 120, 120]}), json!({"point": [100, 80]})] {
|
||||
let e = s.execute("select.object", p.clone()).unwrap_err().to_string();
|
||||
assert!(e.contains("active layer is empty") && e.contains("sampleAllLayers"), "{p}: {e}");
|
||||
assert!(s.active().unwrap().doc.selection.is_none());
|
||||
}
|
||||
// Sampling all layers finds the disc below.
|
||||
s.execute("select.object", json!({"rect": [40, 20, 120, 120], "sampleAllLayers": true})).unwrap();
|
||||
assert!(sel_iou(&s, 200, 160, &inside) > 0.95);
|
||||
// A layer with pixels elsewhere: the rectangle holds none of them.
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.execute("paint.pencil", json!({"points": [[5, 5], [10, 5]], "size": 2, "color": "#000000"})).unwrap();
|
||||
let e = s.execute("select.object", json!({"rect": [60, 60, 100, 80]})).unwrap_err().to_string();
|
||||
assert!(e.contains("no pixels in that area"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_subject_centred_object() {
|
||||
let (mut s, inside) = disc(8);
|
||||
@@ -970,7 +1007,6 @@ mod tests {
|
||||
fn refine_edge_works_on_layer_mask_without_selection() {
|
||||
let mut s = blurred_edge_selected();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
assert!(s.active().unwrap().doc.selection.is_none());
|
||||
assert!(s.active().unwrap().doc.layers[0].mask.is_some());
|
||||
assert!(s.is_enabled("select.refineEdge"));
|
||||
|
||||
@@ -553,7 +553,7 @@ fn clipping_masks_apply_to_every_selected_layer() {
|
||||
// A `layer` param still acts on that layer alone.
|
||||
s.execute("layer.releaseClippingMask", json!({"layer": ids[2]})).unwrap();
|
||||
assert_eq!(clipped(&s), [false, true, false]);
|
||||
assert!(s.execute("layer.createClippingMask", json!({"layer": 999_999})).is_err());
|
||||
assert!(s.execute("layer.createClippingMask", json!({"layer": u64::MAX})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -992,8 +992,8 @@ fn move_to_copy_rejects_bad_params() {
|
||||
for p in [
|
||||
json!({"layer": a, "copy": true}),
|
||||
json!({"layer": a, "target": "x", "copy": true}),
|
||||
json!({"layer": a, "target": 9_999_999, "copy": true}),
|
||||
json!({"layer": 9_999_999, "target": a, "copy": true}),
|
||||
json!({"layer": a, "target": u64::MAX, "copy": true}),
|
||||
json!({"layer": u64::MAX, "target": a, "copy": true}),
|
||||
json!({"layer": a, "target": a, "position": "into", "copy": true}),
|
||||
] {
|
||||
assert!(s.execute("layer.moveTo", p.clone()).is_err(), "{p}");
|
||||
|
||||
@@ -482,7 +482,7 @@ mod tests {
|
||||
bad(&mut s, "type.navigate", json!({"layer": id, "index": 9, "move": "end"}));
|
||||
bad(&mut s, "type.navigate", json!({"layer": id, "index": 0, "move": "lineNext", "x": "no"}));
|
||||
bad(&mut s, "type.navigate", json!({"layer": pixel, "index": 0, "move": "start"}));
|
||||
assert!(matches!(s.execute("type.caret", json!({"layer": 9_999_999, "index": 0})), Err(EngineError::NoLayer(_))));
|
||||
assert!(matches!(s.execute("type.caret", json!({"layer": u64::MAX, "index": 0})), Err(EngineError::NoLayer(_))));
|
||||
// A point on the named layer but outside its text still returns a caret, marked outside.
|
||||
let far = s.execute("type.hitTest", json!({"layer": id, "x": 390, "y": 290})).unwrap();
|
||||
assert_eq!(far["inside"], false);
|
||||
|
||||
@@ -1184,7 +1184,7 @@ mod tests {
|
||||
st.saved_revision = st.revision;
|
||||
}
|
||||
let rev = s.active().unwrap().revision;
|
||||
let unknown = [(doc_id, LayerId(9999)), (photocraft_doc::DocId(u64::MAX), id)];
|
||||
let unknown = [(doc_id, LayerId(u64::MAX)), (photocraft_doc::DocId(u64::MAX), id)];
|
||||
assert!(s.refresh_type_layers(&[&[(doc_id, id)][..], &unknown].concat()).is_empty());
|
||||
assert!(text_layer(&s, id.0).cache.is_some());
|
||||
let st = s.active().unwrap();
|
||||
|
||||
@@ -108,8 +108,9 @@ fn vertical_orientation_renders_columns_inside_the_canvas() {
|
||||
assert!(l.vertical && l.lines.len() == 2);
|
||||
let [x0, y0, x1, y1] = l.bounds().unwrap();
|
||||
assert!(x1 > 0.0 && x0 < -40.0 && y0 >= -1e-3 && y1 > 60.0, "{:?}", l.bounds());
|
||||
// Bad layer ids fail cleanly.
|
||||
assert!(s.execute("type.orientation.vertical", json!({"layer": 9999})).is_err());
|
||||
// Bad layer ids fail cleanly. Not a small number like 9999: ids come from one process-wide
|
||||
// counter, so in a full test run a layer made above can get it (#3343).
|
||||
assert!(s.execute("type.orientation.vertical", json!({"layer": u64::MAX})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -299,7 +300,7 @@ fn type_attaches_to_a_path_and_releases_it() {
|
||||
.unwrap();
|
||||
assert!(s.execute("type.attachToPath", json!({"subpath": 5})).is_err());
|
||||
assert!(s.execute("type.attachToPath", json!({"start": "far"})).is_err());
|
||||
assert!(s.execute("type.attachToPath", json!({"shape": 9999})).is_err());
|
||||
assert!(s.execute("type.attachToPath", json!({"shape": u64::MAX})).is_err());
|
||||
s.execute("type.attachToPath", json!({"start": 4})).unwrap();
|
||||
assert!(matches!(text(&s, id).shape, TextShape::Path { start, .. } if start == 4.0));
|
||||
let on_path = ink(&s, id);
|
||||
|
||||
@@ -105,7 +105,7 @@ fn listed_pixel_methods_can_be_used_to_redefine_variables() {
|
||||
#[test]
|
||||
fn bad_params_are_errors() {
|
||||
let (mut s, _p, badge, _t) = session();
|
||||
assert!(s.execute("image.variables.define", json!({"defs": [{"name": "x", "layer": 999999, "type": "visibility"}]})).is_err());
|
||||
assert!(s.execute("image.variables.define", json!({"defs": [{"name": "x", "layer": u64::MAX, "type": "visibility"}]})).is_err());
|
||||
assert!(s.execute("image.variables.define", json!({"defs": [{"name": "x", "layer": badge.0, "type": "nope"}]})).is_err());
|
||||
assert!(s.execute("image.applyDataSet", json!({"name": "missing"})).is_err());
|
||||
}
|
||||
|
||||
@@ -646,7 +646,6 @@ fn rasterizing_a_vector_mask_keeps_what_the_masks_show() {
|
||||
if let Some((feather, density)) = pm {
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 40, "height": 64})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.edit("mask settings", |doc, _| {
|
||||
let m = doc.layer_mut(id).unwrap().mask.as_mut().unwrap();
|
||||
(m.feather, m.density) = (feather, density);
|
||||
@@ -925,7 +924,7 @@ fn combine_shapes_fails_gracefully() {
|
||||
let (mut s, a, _) = two_selected_rects(8);
|
||||
let before = doc(&s).clone();
|
||||
let history = s.active().unwrap().history.past_len();
|
||||
let bad_params = [json!({"layer": 999_999}), json!({"layer": a, "subpath": 99}), json!({"subpath": 99}), json!({"tolerance": "x", "layer": 999_999})];
|
||||
let bad_params = [json!({"layer": u64::MAX}), json!({"layer": a, "subpath": 99}), json!({"subpath": 99}), json!({"tolerance": "x", "layer": u64::MAX})];
|
||||
for cmd in [
|
||||
"layer.combineShapes.unite",
|
||||
"layer.combineShapes.subtractFrontShape",
|
||||
|
||||
@@ -122,7 +122,7 @@ fn eraser_bad_params_fail_gracefully() {
|
||||
assert!(s.execute("paint.stroke", json!({"erase": true})).is_err());
|
||||
assert!(s.execute("paint.stroke", json!({"erase": true, "points": []})).is_err());
|
||||
assert!(s.execute("paint.stroke", json!({"erase": true, "points": "x"})).is_err());
|
||||
assert!(erase(&mut s, json!({"layer": 99999})).is_err());
|
||||
assert!(erase(&mut s, json!({"layer": u64::MAX})).is_err());
|
||||
assert!(erase(&mut s, json!({"target": "mask"})).is_err(), "no mask");
|
||||
// Absurd coordinates are refused up front (a stroke that long would run billions of dabs).
|
||||
assert!(erase(&mut s, json!({"points": [[0, 0], [f64::MAX, 0.0]]})).is_err());
|
||||
|
||||
@@ -67,7 +67,7 @@ fn a_named_layer_of_the_wrong_kind_or_that_does_not_exist_is_refused() {
|
||||
let r = s.execute("layer.smartObjects.rasterize", json!({"layer": pixels}));
|
||||
assert!(matches!(r, Err(EngineError::Disabled(..))), "{r:?}");
|
||||
// A layer that doesn't exist falls back to the active layer's check, and still fails.
|
||||
assert!(s.execute("layer.smartObjects.rasterize", json!({"layer": 999_999})).is_err());
|
||||
assert!(s.execute("layer.smartObjects.rasterize", json!({"layer": u64::MAX})).is_err());
|
||||
assert!(s.execute("layer.smartObjects.rasterize", json!({"layer": "nope"})).is_err());
|
||||
assert_eq!(s.active().unwrap().doc, before);
|
||||
assert_eq!(active(&s), pixels);
|
||||
|
||||
@@ -45,7 +45,12 @@ fn newly_created_layer_masks_follow_document_depth() {
|
||||
assert_eq!(m.value(20, 20), white);
|
||||
if selected {
|
||||
assert_eq!(m.value(0, 0), 0.0);
|
||||
assert_eq!(d.doc.selection, before.selection, "the selection is unchanged");
|
||||
if command == "layer.layerMask.revealSelection" {
|
||||
// The selection became the mask: Photoshop drops it, as Hide Selection does.
|
||||
assert!(d.doc.selection.is_none(), "{command}: the selection is dropped");
|
||||
} else {
|
||||
assert_eq!(d.doc.selection, before.selection, "the selection is unchanged");
|
||||
}
|
||||
} else {
|
||||
assert_eq!(m.surface.tile_count(), 0, "uniform masks stay sparse");
|
||||
assert_eq!(m.value(-300_000, 300_000), white);
|
||||
@@ -133,7 +138,8 @@ fn mask_creation_preserves_selection_coverage_and_existing_masks() {
|
||||
before.selection.as_ref().unwrap().read_region(before.bounds()),
|
||||
"{depth}-bit coverage is unchanged"
|
||||
);
|
||||
assert_eq!(after.selection, before.selection);
|
||||
let kept = if command == "layer.layerMask.revealSelection" { None } else { before.selection.clone() };
|
||||
assert_eq!(after.selection, kept, "{command}");
|
||||
assert_eq!(after.layers[0].mask, before.layers[0].mask, "creating a mask does not requantize an existing mask");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
use photocraft_engine::{Session, command_specs};
|
||||
use serde_json::{Value, json};
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::sync::mpsc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Mutex, Once, PoisonError, mpsc};
|
||||
use std::time::Duration;
|
||||
|
||||
fn fresh() -> Session {
|
||||
@@ -22,19 +23,41 @@ fn fresh() -> Session {
|
||||
/// 0.3 s even on a heavily loaded machine, so this only catches real hangs.
|
||||
const DEADLINE: Duration = Duration::from_secs(4);
|
||||
|
||||
/// Run `id` with `p` on a fresh session, on a worker thread. `None` if it timed out, else whether
|
||||
/// it finished without panicking (returning Ok or a graceful Err both count).
|
||||
fn run_once(id: &str, p: &Value) -> Option<bool> {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let (id, p) = (id.to_string(), p.clone());
|
||||
std::thread::spawn(move || {
|
||||
let r = catch_unwind(AssertUnwindSafe(|| {
|
||||
let mut s = fresh();
|
||||
let _ = s.execute(&id, p);
|
||||
/// Panics anywhere in the process, counted by a hook. `Session::execute` contains a command's
|
||||
/// panic and returns an ordinary `Err`, so the unwind never reaches `catch_unwind` here; the hook
|
||||
/// still sees it, on whichever thread (rayon workers included) it happened (#4982).
|
||||
static PANICS: AtomicUsize = AtomicUsize::new(0);
|
||||
/// One run at a time, so a panic is charged to the run that caused it.
|
||||
static RUN: Mutex<()> = Mutex::new(());
|
||||
|
||||
/// Run `f` on a worker thread. `None` if it timed out, else whether it finished without
|
||||
/// panicking, contained or not (returning Ok or a graceful Err both count).
|
||||
fn run_watched(f: impl FnOnce() + Send + 'static) -> Option<bool> {
|
||||
static HOOK: Once = Once::new();
|
||||
HOOK.call_once(|| {
|
||||
let default = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
PANICS.fetch_add(1, Ordering::SeqCst);
|
||||
default(info);
|
||||
}));
|
||||
});
|
||||
let _one = RUN.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
let before = PANICS.load(Ordering::SeqCst);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
std::thread::spawn(move || {
|
||||
let r = catch_unwind(AssertUnwindSafe(f));
|
||||
let _ = tx.send(r.is_ok());
|
||||
});
|
||||
rx.recv_timeout(DEADLINE).ok()
|
||||
rx.recv_timeout(DEADLINE).ok().map(|ok| ok && PANICS.load(Ordering::SeqCst) == before)
|
||||
}
|
||||
|
||||
/// Run `id` with `p` on a fresh session; see [`run_watched`].
|
||||
fn run_once(id: &str, p: &Value) -> Option<bool> {
|
||||
let (id, p) = (id.to_string(), p.clone());
|
||||
run_watched(move || {
|
||||
let mut s = fresh();
|
||||
let _ = s.execute(&id, p);
|
||||
})
|
||||
}
|
||||
|
||||
/// `Err` with a reason on panic or hang, `Ok` otherwise.
|
||||
@@ -80,3 +103,17 @@ fn no_command_panics_or_hangs_on_adversarial_params() {
|
||||
}
|
||||
assert!(bad.is_empty(), "{} commands panicked or hung:\n{}", bad.len(), bad.join("\n"));
|
||||
}
|
||||
|
||||
/// #4982: a panic the code under test contains still fails the run; a graceful `Err` does not.
|
||||
#[test]
|
||||
fn contained_panics_count_and_graceful_errors_do_not() {
|
||||
let contained = run_watched(|| {
|
||||
let _ = catch_unwind(|| panic!("contained, as Session::execute does"));
|
||||
});
|
||||
assert_eq!(contained, Some(false));
|
||||
let graceful = run_watched(|| {
|
||||
let mut s = fresh();
|
||||
assert!(s.execute("layer.delete", json!({"layer": 999999})).is_err());
|
||||
});
|
||||
assert_eq!(graceful, Some(true));
|
||||
}
|
||||
@@ -140,6 +140,6 @@ fn bad_targets_fail_gracefully() {
|
||||
}
|
||||
let mut sc = scene();
|
||||
for id in ["layer.rasterize.layer", "layer.rasterize.shape", "layer.rasterize.smartObject"] {
|
||||
assert!(sc.s.execute(id, json!({"layer": 9_999_999})).is_err(), "{id}: no such layer");
|
||||
assert!(sc.s.execute(id, json!({"layer": u64::MAX})).is_err(), "{id}: no such layer");
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,6 @@ fn bad_targets_fail_gracefully() {
|
||||
}
|
||||
let mut sc = scene();
|
||||
for id in ["layer.layerMask.revealAll", "layer.layerStyle.pasteLayerStyle", "layer.layerStyle.clear"] {
|
||||
assert!(sc.s.execute(id, json!({"layer": 9_999_999})).is_err(), "{id}: no such layer");
|
||||
assert!(sc.s.execute(id, json!({"layer": u64::MAX})).is_err(), "{id}: no such layer");
|
||||
}
|
||||
}
|
||||
@@ -199,12 +199,33 @@ pub fn list_recovery(recovery_dir: &Path) -> Vec<RecoveryEntry> {
|
||||
if bundle.join(crate::store::MANIFEST).is_file() {
|
||||
out.push(RecoveryEntry { info, bundle });
|
||||
}
|
||||
} else if e.file_type().is_ok_and(|ft| ft.is_dir())
|
||||
&& let Some(entry) = sidecarless_entry(recovery_dir, &p)
|
||||
{
|
||||
out.push(entry);
|
||||
}
|
||||
}
|
||||
out.sort_by(|a, b| b.info.saved_at.cmp(&a.info.saved_at).then(a.info.key.cmp(&b.info.key)));
|
||||
out
|
||||
}
|
||||
|
||||
/// A committed `<key>.pcraft` bundle (its manifest is written last) whose sidecar was never
|
||||
/// published, e.g. a crash during a document's first autosave. The metadata is rebuilt from the
|
||||
/// manifest (read like a load reads it) and its modification time. Incomplete bundles (no
|
||||
/// readable manifest) and bundles with anything at the sidecar's path are not entries.
|
||||
fn sidecarless_entry(recovery_dir: &Path, bundle: &Path) -> Option<RecoveryEntry> {
|
||||
let key = bundle.file_name()?.to_str()?.strip_suffix(".pcraft")?;
|
||||
if key.is_empty() || sanitize(key) != key || std::fs::symlink_metadata(recovery_dir.join(format!("{key}.json"))).is_ok() {
|
||||
return None;
|
||||
}
|
||||
let meta = std::fs::symlink_metadata(bundle.join(crate::store::MANIFEST)).ok().filter(|m| m.is_file())?;
|
||||
let source = crate::store::DirSource { root: bundle.to_path_buf() };
|
||||
let manifest = crate::store::read_manifest(&source, &crate::LoadOptions::default()).ok()?;
|
||||
let saved_at = meta.modified().ok().and_then(|t| t.duration_since(UNIX_EPOCH).ok()).map_or(0, |d| d.as_secs());
|
||||
let info = RecoveryInfo { key: key.to_string(), document_name: manifest.document.name, original_path: None, saved_at, revision: 0 };
|
||||
Some(RecoveryEntry { info, bundle: bundle.to_path_buf() })
|
||||
}
|
||||
|
||||
/// Load a recovered document.
|
||||
pub fn recover(entry: &RecoveryEntry) -> Result<Document> {
|
||||
crate::load_path(&entry.bundle)
|
||||
@@ -292,8 +313,9 @@ impl RecoveryStore {
|
||||
const ORPHAN_AGE: std::time::Duration = std::time::Duration::from_secs(24 * 60 * 60);
|
||||
|
||||
/// Best-effort removal of recovery data nothing can ever load or clean up:
|
||||
/// - `<key>.pcraft` bundle folders with no `<key>.json` sidecar (a crash during a document's
|
||||
/// first autosave: the sidecar is written after the bundle, and `list_recovery` skips them);
|
||||
/// - `<key>.pcraft` bundle folders with no `<key>.json` sidecar and no readable manifest (a
|
||||
/// crash in the middle of a document's first autosave). A sidecar-less bundle whose manifest
|
||||
/// was committed is complete and listed by `list_recovery`, so it is kept;
|
||||
/// - `*.pcsave.tmp` files left by an interrupted atomic write (see [`crate::atomic::temp_name`])
|
||||
/// that another process created.
|
||||
///
|
||||
@@ -321,7 +343,8 @@ fn sweep_orphans(recovery_dir: &Path, min_age: std::time::Duration) {
|
||||
// Anything at the sidecar's path (even a broken one) keeps the bundle.
|
||||
let has_sidecar = std::fs::symlink_metadata(recovery_dir.join(format!("{key}.json"))).is_ok();
|
||||
let parts = [path.clone(), path.join("tiles"), path.join("blobs")];
|
||||
if !has_sidecar && parts.iter().all(|p| untouched_for(p, min_age, true)) {
|
||||
// A committed bundle is recoverable work: keep exactly what `list_recovery` lists.
|
||||
if !has_sidecar && sidecarless_entry(recovery_dir, &path).is_none() && parts.iter().all(|p| untouched_for(p, min_age, true)) {
|
||||
let _ = std::fs::remove_dir_all(&path);
|
||||
} else {
|
||||
bundles.extend(parts);
|
||||
@@ -437,4 +460,41 @@ mod tests {
|
||||
assert_eq!(recover(&entries[0]).unwrap(), *doc);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn a_committed_bundle_without_a_sidecar_is_listed_and_survives_the_sweep() {
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"pcraft-nosidecar-{}-{}",
|
||||
std::process::id(),
|
||||
SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_nanos()).unwrap_or(0)
|
||||
));
|
||||
let doc =
|
||||
Arc::new(Document::new("Lost", photocraft_doc::Size { width: 4, height: 4 }, photocraft_color::ColorMode::Rgb, photocraft_color::SampleType::U8));
|
||||
let saver = Autosaver::new(&dir, "first");
|
||||
saver.request(doc.clone(), 1, None, SaveOptions::default());
|
||||
assert!(saver.flush().is_some_and(|r| r.is_ok()));
|
||||
// The crash: the bundle was committed, the sidecar never published.
|
||||
std::fs::remove_file(dir.join("first.json")).unwrap();
|
||||
|
||||
let entries = list_recovery(&dir);
|
||||
assert_eq!(entries.len(), 1, "the committed bundle is discoverable");
|
||||
assert_eq!((entries[0].info.key.as_str(), entries[0].info.document_name.as_str()), ("first", "Lost"));
|
||||
assert_eq!(recover(&entries[0]).unwrap(), *doc);
|
||||
|
||||
sweep_orphans(&dir, std::time::Duration::ZERO);
|
||||
assert!(dir.join("first.pcraft").is_dir(), "aged cleanup keeps a committed bundle");
|
||||
|
||||
// Incomplete bundles (no manifest, or one that does not read) are neither listed nor kept.
|
||||
let partial = dir.join("partial.pcraft");
|
||||
std::fs::create_dir_all(partial.join("tiles")).unwrap();
|
||||
let broken = dir.join("broken.pcraft");
|
||||
std::fs::create_dir_all(&broken).unwrap();
|
||||
std::fs::write(broken.join("manifest.json"), b"{").unwrap();
|
||||
assert_eq!(list_recovery(&dir).len(), 1);
|
||||
sweep_orphans(&dir, std::time::Duration::ZERO);
|
||||
assert!(!partial.exists() && !broken.exists());
|
||||
assert!(dir.join("first.pcraft").is_dir());
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
@@ -1097,9 +1097,10 @@ impl<'a> Planner<'a> {
|
||||
};
|
||||
for &(i, e) in &rev {
|
||||
if let Effect::DropShadow(s) = e {
|
||||
// The layer hides the shadow beneath it where its fill is see-through.
|
||||
// The layer hides the shadow beneath it where its fill is see-through, and wholly
|
||||
// in a mode that blends with it (as the CPU renderer: `shadow_see_through`).
|
||||
let flags = if s.knocks_out { F_KNOCKOUT } else { 0 };
|
||||
let see_through = 1.0 - layer.fill_opacity.clamp(0.0, 1.0);
|
||||
let see_through = photocraft_compose::effects::shadow_see_through(layer);
|
||||
w = self.paint_k(
|
||||
w,
|
||||
content,
|
||||
|
||||
@@ -527,10 +527,17 @@ fn fit(w: u32, h: u32, v: Vec<f32>, max: u32) -> (u32, u32, Vec<f32>) {
|
||||
let k = (w.max(h) as f32 / max as f32).max(1.0);
|
||||
let (nw, nh) = (((w as f32 / k).round() as u32).clamp(1, max), ((h as f32 / k).round() as u32).clamp(1, max));
|
||||
let mut out = vec![0.0f32; nw as usize * nh as usize];
|
||||
// Source rows/columns `[i * n / m, (i + 1) * n / m)` (at least one) for output index `i` of
|
||||
// `m`; in u64, as `(i + 1) * n` passes u32 for a plane over 2^32 / `max` long. The parsers'
|
||||
// edge caps keep today's inputs below that, but this function should not depend on them.
|
||||
let span = |i: u32, n: u32, m: u32| {
|
||||
let at = |k: u32| usize::try_from(u64::from(k) * u64::from(n) / u64::from(m)).unwrap_or(usize::MAX);
|
||||
(at(i), at(i + 1).max(at(i).saturating_add(1)).min(n as usize))
|
||||
};
|
||||
for y in 0..nh {
|
||||
let (y0, y1) = ((y * h / nh) as usize, (((y + 1) * h / nh) as usize).max((y * h / nh) as usize + 1).min(h as usize));
|
||||
let (y0, y1) = span(y, h, nh);
|
||||
for x in 0..nw {
|
||||
let (x0, x1) = ((x * w / nw) as usize, (((x + 1) * w / nw) as usize).max((x * w / nw) as usize + 1).min(w as usize));
|
||||
let (x0, x1) = span(x, w, nw);
|
||||
let (mut sum, mut n) = (0.0, 0usize);
|
||||
for yy in y0..y1 {
|
||||
for xx in x0..x1 {
|
||||
@@ -593,3 +600,18 @@ fn pattern_tile(p: &PsdPattern) -> Option<GrayTile> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod fit_tests {
|
||||
use super::fit;
|
||||
|
||||
/// A tall, narrow plane: `(y + 1) * h` passes `u32::MAX` once `h` is over 2^32 / `max` rows.
|
||||
/// The ABR and pattern parsers cap edges well below that, but `fit` must not rely on it.
|
||||
#[test]
|
||||
fn fit_tall_planes_without_overflow() {
|
||||
let h = 5_000_000u32;
|
||||
let (w, nh, out) = fit(1, h, vec![1.0; h as usize], 1024);
|
||||
assert_eq!((w, nh), (1, 1024));
|
||||
assert!(out.iter().all(|v| (*v - 1.0).abs() < 1e-6), "every output row averages real input rows");
|
||||
}
|
||||
}
|
||||
@@ -106,12 +106,15 @@ fn smooth_ease(u: f32) -> f32 {
|
||||
/// Colour at `t` for sorted stops (positions in 0..1) in `m`'s space.
|
||||
fn eval(stops: &[(f32, [f32; 3])], mids: &[f32], smooth: f32, t: f32, m: Method) -> [f32; 3] {
|
||||
let n = stops.len();
|
||||
if t <= stops[0].0 {
|
||||
return stops[0].1;
|
||||
let (Some(first), Some(last)) = (stops.first(), stops.last()) else { return [0.0; 3] };
|
||||
// A lone stop (even at a NaN position, which neither test below catches) is the colour.
|
||||
if t <= first.0 || n < 2 {
|
||||
return first.1;
|
||||
}
|
||||
if t >= stops[n - 1].0 {
|
||||
return stops[n - 1].1;
|
||||
if t >= last.0 {
|
||||
return last.1;
|
||||
}
|
||||
// From here `stops[i + 1]` and the tangents' `n - 2` are in range: `i < n - 1` and `n >= 2`.
|
||||
let i = stops.windows(2).position(|w| t >= w[0].0 && t <= w[1].0).unwrap_or(0);
|
||||
let (t0, t1) = (stops[i].0, stops[i + 1].0);
|
||||
let h = (t1 - t0).max(1e-6);
|
||||
@@ -281,4 +284,14 @@ mod tests {
|
||||
let s = bake(vec![(0.0, Color::BLACK), (1.0, Color::WHITE)], &[0.25], 0.0, Method::Classic);
|
||||
assert!((at(&s, 0.25)[0] - 0.5).abs() < 0.01);
|
||||
}
|
||||
|
||||
/// `eval` guards its own stops instead of relying on `bake`'s two-stop check.
|
||||
#[test]
|
||||
fn eval_with_fewer_than_two_stops_does_not_index_out_of_range() {
|
||||
assert_eq!(eval(&[], &[], 1.0, 0.5, Method::Smooth), [0.0; 3]);
|
||||
let lone = [(f32::NAN, [0.25, 0.5, 0.75])];
|
||||
for m in [Method::Classic, Method::Smooth] {
|
||||
assert_eq!(eval(&lone, &[], 1.0, 0.5, m), [0.25, 0.5, 0.75]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1636,6 +1636,7 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c
|
||||
|
||||
// Resources.
|
||||
let mut resources = vec![
|
||||
// hRes/vRes are always pixels per inch. The display unit written here is inches.
|
||||
ImageResource::new(ids::RESOLUTION_INFO, ResolutionInfo::from_dpi(f64::from(doc.resolution_dpi)).to_bytes()),
|
||||
ImageResource::new(ids::GLOBAL_ANGLE, (doc.global_light.angle.round() as i32).to_be_bytes().to_vec()),
|
||||
ImageResource::new(ids::GLOBAL_ALTITUDE, (doc.global_light.altitude.round() as i32).to_be_bytes().to_vec()),
|
||||
|
||||
@@ -673,8 +673,9 @@ pub fn psd_to_document_with(file: &PsdFile, ctl: &photocraft_raster::Interrupt)
|
||||
match r.id {
|
||||
ids::RESOLUTION_INFO => {
|
||||
if let Ok(ri) = photocraft_psd::ResolutionInfo::from_bytes(&r.data) {
|
||||
let ppi = |res: f64, unit: u16| if unit == 2 { res * 2.54 } else { res };
|
||||
let (x, y) = (ppi(ri.h_res(), ri.h_res_unit), ppi(ri.v_res(), ri.v_res_unit));
|
||||
// Fixed 16.16 hRes/vRes are pixels per inch. The unit shorts only
|
||||
// say how to show that number (1 = px/in, 2 = px/cm).
|
||||
let (x, y) = (ri.h_res(), ri.v_res());
|
||||
doc.resolution_dpi = x as f32;
|
||||
warnings.extend(crate::unequal_resolution_warning(x, y));
|
||||
}
|
||||
|
||||
@@ -203,3 +203,36 @@ fn merged_oracle_does_not_treat_extra_channels_as_transparency() {
|
||||
assert_eq!(merged_composite(&file).unwrap(), vec![[2.0, 2.0, 2.0, 1.0]], "{mode:?}");
|
||||
}
|
||||
}
|
||||
|
||||
// Photoshop saves a transparent 32-bit document with a positive layer count and an `Mt32`
|
||||
// ("Saving Merged Transparency") global block: the merged image's first extra channel, named
|
||||
// "Transparency", is its transparency (psd-tools transparentbg.psd). The oracle reads it as the
|
||||
// composite's alpha, and opening the file doesn't turn it into an alpha channel.
|
||||
#[test]
|
||||
fn mt32_marks_the_merged_transparency() {
|
||||
let mut doc = Document::new("transparent", Size::new(2, 1), ColorMode::Rgb, SampleType::F32);
|
||||
let fmt = doc.pixel_format();
|
||||
let mut layer = photocraft_doc::Layer::raster("shape", fmt);
|
||||
if let Some(s) = layer.surface_mut() {
|
||||
s.fill_rect(photocraft_geom::Rect::new(0, 0, 1, 1), &[0.0, 0.0, 0.0, 1.0]);
|
||||
}
|
||||
doc.layers.push(layer);
|
||||
let mut file = PsdFile::from_bytes(&export_psd(&doc)).unwrap();
|
||||
file.header.channels = 4;
|
||||
if let Some(li) = file.layer_info.as_mut() {
|
||||
li.merged_alpha = false;
|
||||
}
|
||||
file.image_data.compression = Compression::Raw;
|
||||
let plane = |v: [f32; 2]| v.into_iter().flat_map(f32::to_be_bytes).collect::<Vec<u8>>();
|
||||
file.image_data.data = [plane([0.0, 1.0]), plane([0.0, 1.0]), plane([0.0, 1.0]), plane([1.0, 0.0])].concat();
|
||||
let name: Vec<u8> = [0u8, 0, 0, 13].into_iter().chain("Transparency\0".encode_utf16().flat_map(u16::to_be_bytes)).collect();
|
||||
file.resources.retain(|r| r.id != 1045);
|
||||
file.resources.push(photocraft_psd::ImageResource::new(1045, name));
|
||||
assert!(!file.merged_has_alpha(), "a positive layer count alone");
|
||||
file.global_blocks.push(photocraft_psd::TaggedBlock::new(*b"Mt32", Vec::new()));
|
||||
assert!(file.merged_has_alpha());
|
||||
let merged = merged_composite(&file).unwrap();
|
||||
assert_eq!(merged.iter().map(|p| p[3]).collect::<Vec<_>>(), vec![1.0, 0.0]);
|
||||
let opened = import("transparent.psd", &file.to_bytes().unwrap()).unwrap();
|
||||
assert!(opened.document.channels.is_empty(), "{:?}", opened.document.channels.iter().map(|c| &c.name).collect::<Vec<_>>());
|
||||
}
|
||||
@@ -460,13 +460,18 @@ fn guides_and_alpha_names_roundtrip() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolution_in_cm_converted() {
|
||||
fn resolution_info_cm_display_unit_stays_pixels_per_inch() {
|
||||
let mut f = testgen::small(Version::Psd, Compression::Raw);
|
||||
let mut ri = photocraft_psd::ResolutionInfo::from_dpi(100.0);
|
||||
let mut ri = photocraft_psd::ResolutionInfo::from_dpi(300.0);
|
||||
ri.h_res_unit = 2;
|
||||
ri.v_res_unit = 2;
|
||||
f.resources[0] = photocraft_psd::ImageResource::new(1005, ri.to_bytes());
|
||||
let (d, _) = psd_to_document(&f);
|
||||
assert!((d.resolution_dpi - 254.0).abs() < 1e-3);
|
||||
assert!((d.resolution_dpi - 300.0).abs() < 1e-3, "{}", d.resolution_dpi);
|
||||
let out = document_to_psd(&d);
|
||||
let written = out.resolution().unwrap();
|
||||
assert!((written.h_res() - 300.0).abs() < 1e-3, "{}", written.h_res());
|
||||
assert!((written.v_res() - 300.0).abs() < 1e-3, "{}", written.v_res());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -59,13 +59,27 @@ fn psd_with_equal_axes_opens_silently() {
|
||||
let r = import("x.psd", &psd(ResolutionInfo::from_dpi(300.0))).unwrap();
|
||||
assert!((r.document.resolution_dpi - 300.0).abs() < 1e-3, "{}", r.document.resolution_dpi);
|
||||
assert!(resolution_notes(&r).is_empty(), "{:?}", r.warnings);
|
||||
// Each axis is read in its own unit: 100 pixels per centimetre on both is 254 ppi on both.
|
||||
let mut cm = ResolutionInfo::from_dpi(100.0);
|
||||
}
|
||||
|
||||
/// Resource 1005 stores 300 ppi even when the display unit is centimetres. Scaling
|
||||
/// that fixed-point value by 2.54 opened the file at 762 ppi (#5201).
|
||||
#[test]
|
||||
fn resolution_info_cm_display_unit_is_pixels_per_inch() {
|
||||
let mut cm = ResolutionInfo::from_dpi(300.0);
|
||||
cm.h_res_unit = 2;
|
||||
cm.v_res_unit = 2;
|
||||
cm.width_unit = 2;
|
||||
cm.height_unit = 2;
|
||||
let r = import("x.psd", &psd(cm)).unwrap();
|
||||
assert!((r.document.resolution_dpi - 254.0).abs() < 1e-3, "{}", r.document.resolution_dpi);
|
||||
assert!((r.document.resolution_dpi - 300.0).abs() < 1e-3, "{}", r.document.resolution_dpi);
|
||||
assert!(resolution_notes(&r).is_empty(), "{:?}", r.warnings);
|
||||
|
||||
let out = export(&r.document, "out.psd", &ExportOptions::default()).unwrap();
|
||||
let file = photocraft_psd::PsdFile::from_bytes(&out.bytes).unwrap();
|
||||
let written = file.resolution().unwrap();
|
||||
assert!((written.h_res() - 300.0).abs() < 1e-3, "{}", written.h_res());
|
||||
assert!((written.v_res() - 300.0).abs() < 1e-3, "{}", written.v_res());
|
||||
assert_eq!((written.h_res_unit, written.v_res_unit), (1, 1));
|
||||
}
|
||||
|
||||
/// A layered TIFF opens through the PSD importer with the TIFF's own resolution tags.
|
||||
|
||||
@@ -272,7 +272,10 @@ impl PsdFile {
|
||||
self.image_data.decode(&self.header)
|
||||
}
|
||||
|
||||
/// `true` if the merged image carries a transparency channel.
|
||||
/// `true` if the merged image carries a transparency channel: its first extra channel, when
|
||||
/// the layer count was stored negative or a "Saving Merged Transparency" global block (`Mtrn`,
|
||||
/// `Mt16`, `Mt32`) is present. Photoshop marks 32-bit documents with `Mt32` and a positive
|
||||
/// layer count (psd-tools transparentbg.psd).
|
||||
pub fn merged_has_alpha(&self) -> bool {
|
||||
let Some(color) = self.header.color_mode.color_channels() else {
|
||||
return false;
|
||||
@@ -280,8 +283,9 @@ impl PsdFile {
|
||||
if self.header.channels <= color {
|
||||
return false;
|
||||
}
|
||||
let marked = self.global_blocks.iter().any(|b| matches!(&b.key, b"Mtrn" | b"Mt16" | b"Mt32"));
|
||||
match &self.layer_info {
|
||||
Some(li) => li.merged_alpha,
|
||||
Some(li) => li.merged_alpha || marked,
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,20 +45,24 @@ pub struct ImageResource {
|
||||
}
|
||||
|
||||
/// Fixed-point resolution info (resource 1005).
|
||||
///
|
||||
/// `h_res_fixed` and `v_res_fixed` are always pixels per inch (16.16 fixed).
|
||||
/// `h_res_unit` and `v_res_unit` only say how to display that number
|
||||
/// (1 = pixels/inch, 2 = pixels/cm) and do not rescale the stored value.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ResolutionInfo {
|
||||
/// Horizontal resolution, 16.16 fixed point (pixels per inch/cm).
|
||||
/// Horizontal resolution, 16.16 fixed point, always pixels per inch.
|
||||
pub h_res_fixed: u32,
|
||||
/// 1 = pixels per inch, 2 = pixels per cm.
|
||||
/// Display unit for the horizontal resolution (1 = px/in, 2 = px/cm).
|
||||
pub h_res_unit: u16,
|
||||
/// Display unit for width (1 in, 2 cm, 3 pt, 4 pica, 5 column).
|
||||
/// Ruler unit for width (1 in, 2 cm, 3 pt, 4 pica, 5 column).
|
||||
pub width_unit: u16,
|
||||
/// Vertical resolution, 16.16 fixed.
|
||||
/// Vertical resolution, 16.16 fixed point, always pixels per inch.
|
||||
pub v_res_fixed: u32,
|
||||
/// Vertical resolution unit.
|
||||
/// Display unit for the vertical resolution (1 = px/in, 2 = px/cm).
|
||||
pub v_res_unit: u16,
|
||||
/// Display unit for height.
|
||||
/// Ruler unit for height (1 in, 2 cm, 3 pt, 4 pica, 5 column).
|
||||
pub height_unit: u16,
|
||||
}
|
||||
|
||||
@@ -68,11 +72,11 @@ impl ResolutionInfo {
|
||||
let f = (dpi * 65536.0).round().clamp(0.0, u32::MAX as f64) as u32;
|
||||
ResolutionInfo { h_res_fixed: f, h_res_unit: 1, width_unit: 1, v_res_fixed: f, v_res_unit: 1, height_unit: 1 }
|
||||
}
|
||||
/// Horizontal resolution as float.
|
||||
/// Horizontal resolution in pixels per inch.
|
||||
pub fn h_res(&self) -> f64 {
|
||||
f64::from(self.h_res_fixed) / 65536.0
|
||||
}
|
||||
/// Vertical resolution as float.
|
||||
/// Vertical resolution in pixels per inch.
|
||||
pub fn v_res(&self) -> f64 {
|
||||
f64::from(self.v_res_fixed) / 65536.0
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ fn stale_targets_and_invalid_colors_never_apply_or_leave_preview() {
|
||||
app.ui.dialog_mut(picker).unwrap().fields.insert(TARGET.into(), json!(null));
|
||||
}
|
||||
_ => {
|
||||
app.ui.dialog_mut(parent).unwrap().fields.insert("layer".into(), json!(999999));
|
||||
app.ui.dialog_mut(parent).unwrap().fields.insert("layer".into(), json!(u64::MAX));
|
||||
}
|
||||
}
|
||||
let current_parent = app.ui.dialogs.iter().find(|d| d.id == parent).cloned();
|
||||
|
||||
@@ -223,7 +223,6 @@ fn dragging_the_mask_thumbnail_to_trash_asks_to_apply_or_delete_it() {
|
||||
s.execute("layer.layerMask.delete", json!({"layer": masked})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 100, "y": 0, "width": 100, "height": 100})).unwrap();
|
||||
s.execute("layer.layerMask.revealSelection", json!({"layer": masked})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
let mut h = harness(s, 0, 1.0, 290.0);
|
||||
let drag_mask = |h: &mut Harness<'_, PhotocraftApp>| {
|
||||
let from = recorded(&h.ctx, masked).unwrap().0.into_iter().find(|(k, _)| *k == MaskKind::Pixel).unwrap().1.center();
|
||||
@@ -595,7 +594,7 @@ fn mask_view_gestures_fail_gracefully_without_a_mask() {
|
||||
h.run_steps(2);
|
||||
// A stale view (layer gone) draws nothing instead of panicking.
|
||||
h.state_mut().session.active_mut().unwrap().channel_view.layer_mask = Some(photocraft_engine::mask_view_cmds::LayerMaskView {
|
||||
layer: photocraft_doc::LayerId(987_654),
|
||||
layer: photocraft_doc::LayerId(u64::MAX),
|
||||
mode: photocraft_engine::mask_view_cmds::MaskViewMode::Gray,
|
||||
});
|
||||
assert!(canvas_px(&h).is_none());
|
||||
|
||||
@@ -137,7 +137,7 @@ fn a_stale_or_bad_prompt_fails_gracefully() {
|
||||
app.run("layer.rasterize.type", json!({})).unwrap();
|
||||
assert!(crate::dialogs::confirm(&mut app, id).is_err());
|
||||
// Garbage fields.
|
||||
for f in [json!({"__rasterize": "plaid", "layer": 1}), json!({"__rasterize": "type"}), json!({"__rasterize": "type", "layer": 999_999})] {
|
||||
for f in [json!({"__rasterize": "plaid", "layer": 1}), json!({"__rasterize": "type"}), json!({"__rasterize": "type", "layer": u64::MAX})] {
|
||||
let id = app.ui.open_dialog(crate::state::DialogKind::Command, f.as_object().unwrap().clone());
|
||||
assert!(crate::dialogs::confirm(&mut app, id).is_err(), "{f}");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# PhotoCraft architecture
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** minor (current-state summary added; the design plan below is kept, with its deviations listed) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (workspace size and test counts recounted; current-state summary added; the design plan below is kept, with its deviations listed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
## Current state (2026-10-10)
|
||||
|
||||
@@ -8,9 +8,9 @@ What exists on `main` today. The numbered sections below are the original design
|
||||
2026-09-30; where the code differs, this summary wins.
|
||||
|
||||
- **Workspace:** 25 library crates under `crates/`, 3 apps (`photocraft` desktop, `photocraft-cli`,
|
||||
`photocraft-web`), `xtask`, an example plug-in and 5 fuzz crates; ~393,000 lines of Rust in
|
||||
~1,020 files; ~5,460 `#[test]` functions (ui-egui 1,677, engine 1,237, algo 408, io 377,
|
||||
codecs 325, psd 263). Crate map and layers: [`AGENTS.md`](../AGENTS.md) §2 and
|
||||
`photocraft-web`), `xtask`, an example plug-in and 5 fuzz crates; ~539,000 lines of Rust in
|
||||
~1,310 files; ~8,040 `#[test]` functions (ui-egui 2,809, engine 1,796, algo 572, io 539,
|
||||
codecs 426, psd 341), counted 2026-10-13. Crate map and layers: [`AGENTS.md`](../AGENTS.md) §2 and
|
||||
`xtask/src/layers.rs` (enforced by `cargo xtask layers`).
|
||||
- **UI toolkit:** decided: egui/eframe on wgpu (no webview, no JavaScript). The same Rust builds
|
||||
to WebAssembly for the browser (trunk + wasm-bindgen).
|
||||
@@ -588,5 +588,6 @@ Each phase ends with a demoable build and green CI on all targets. Phases 8–10
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-13 | minor | Workspace size and `#[test]` counts recounted (393k → 539k lines, 5,460 → 8,040 tests); other current-state figures unchanged |
|
||||
| 2026-10-10 | minor | Current-state summary and deviations from the plan; status line; broken link to `photoshop-parity.md` repointed to `target-app-parity.md` |
|
||||
| 2026-09-30 | major | Design plan v1 |
|
||||
@@ -1,6 +1,6 @@
|
||||
# Brush and painting parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view; Color Replacement is a live toolbar tool; no brush-feel estimate changed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
Painting is where Photoshop users notice differences first, so it gets its own checklist: the
|
||||
brush engine (`crates/paint/src/brush.rs`), the Brush Settings UI
|
||||
@@ -99,7 +99,7 @@ tablets against Photoshop side by side.
|
||||
| Blur, Sharpen, Smudge (premultiplied, Sample All Layers, spacing) | done | BUG-207-2/3, #2171 |
|
||||
| Dodge, Burn, Sponge | done | |
|
||||
| Background Eraser, Magic Eraser | done | |
|
||||
| Color Replacement | missing as a tool | engine command exists |
|
||||
| Color Replacement | done | |
|
||||
| Quick Selection (brush-driven) | done | |
|
||||
|
||||
## Presets
|
||||
@@ -115,6 +115,7 @@ tablets against Photoshop side by side.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-13 | minor | Stale "missing tool" row corrected against main: Color Replacement (`paint.colorReplacement`) is a live toolbar tool; no brush-feel estimate changed |
|
||||
| 2026-10-10 | major | First version, from a source audit and the open issues |
|
||||
| 2026-10-11 | minor | `~` held with the Brush or Pencil erases with that tool's brush, and Clear joins their Mode menus (#3439) |
|
||||
| 2026-10-12 | minor | Five Brush Settings switch rows toggle without selecting a properties pane; Smoothing has a default-on switch and retains its settings while disabled (#4283). No brush-feel estimate changed. |
|
||||
|
||||
+1
-1
@@ -264,7 +264,7 @@ A typical agent loop (place inputs under the configured read root and outputs un
|
||||
|
||||
`crates/cms` is our own pure-Rust ICC engine (v2/v4 parsing, matrix/TRC and LUT profiles, all four
|
||||
intents, black point compensation). It ships CC0 built-in profiles, including a synthetic
|
||||
"Photocraft Coated CMYK", because Adobe's CMYK profiles are proprietary (see `crates/cms/README.md`).
|
||||
"PhotoCraft Coated CMYK", because Adobe's CMYK profiles are proprietary (see `crates/cms/README.md`).
|
||||
|
||||
- Documents carry an optional embedded ICC profile (`Document::icc_profile`); `edit.assignProfile`
|
||||
and `edit.convertToProfile` change it. Mode changes (`image.mode.*`) convert through cms.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# File-format parity
|
||||
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-14 · **Change:** minor (TIFF alpha channels open and save, LZW/ZIP for scripted saves, #5301; earlier: palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-14 · **Change:** minor (TIFF alpha channels open and save, LZW/ZIP for scripted saves, #5301; earlier: PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
Every format Photoshop 2026 (27.11.0) reads or writes, with PhotoCraft's support, fidelity and
|
||||
tests. Photoshop's list comes from its `Info.plist` `CFBundleDocumentTypes`, the PiPL read/write
|
||||
@@ -143,6 +143,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-14 | minor | A TIFF's alpha channel (Photoshop's unspecified extra sample) opens as a named alpha channel and the first alpha channel saves back; scripted saves take `tiffCompression` (#5301) |
|
||||
| 2026-10-13 | minor | PSD: a "Saving Merged Transparency" global block (`Mtrn`, `Mt16`, `Mt32`; Photoshop's 32-bit documents keep a positive layer count) marks the merged image's first extra channel as its transparency: opening such a file no longer adds a "Transparency" alpha channel, and the oracle compares psd-tools transparentbg.psd's alpha (83.7 % → 0.9 % of pixels off; its shape edges remain) |
|
||||
| 2026-10-13 | minor | Palette PNGs open in Indexed Color mode (#4804) |
|
||||
| 2026-10-12 | minor | `.atn`: 112 events mapped (Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, points, Bitmap) |
|
||||
| 2026-10-12 | minor | DDS textures open, read-only (#1327) |
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
# Where PhotoCraft falls short of Photoshop
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (G10: a TIFF's first alpha channel opens and saves, #5301; earlier: G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (G10: a TIFF's first alpha channel opens and saves, #5301; earlier: G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact
|
||||
on the way to beta. This is the work list agents pick from: take the highest-ranked entry that
|
||||
@@ -54,8 +54,7 @@ what an agent can't finish alone.
|
||||
scripted check there) is the only real oracle.
|
||||
|
||||
### G6. Missing tools
|
||||
- **Missing (4 of 68):** Color Replacement (engine command exists), Art
|
||||
History Brush, Add Anchor Point, Delete Anchor Point. Convert Point landed (#3204). Freeform
|
||||
- **Missing (1 of 68):** Art History Brush. Convert Point landed (#3204). Freeform
|
||||
Pen and Curvature Pen landed (#1054); Color Sampler landed (#1046, `view.colorSamplers.*`); Horizontal and Vertical Type Mask landed (#1055,
|
||||
`type.createSelection`); Perspective Crop landed (#1043, `image.perspectiveCrop`); Frame landed
|
||||
(#2914).
|
||||
@@ -264,6 +263,7 @@ what an agent can't finish alone.
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-14 | minor | G10: TIFF alpha channels narrowed to those beyond the first (#5301) |
|
||||
| 2026-10-13 | minor | G6: stale "missing tool" list corrected against `main` — Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (P flyout, #4144) are live tools, so the toolbox is 67 of 68 and Art History Brush is the only one missing; no percentage or estimate changed |
|
||||
| 2026-10-13 | minor | G4: Hue Jitter amount-track appearance (#3825, partial); no readiness percentage or estimate changed |
|
||||
| 2026-10-13 | minor | G4: minimum inputs in Shape Dynamics and Transfer follow their Control (#3825, partial); no readiness percentage or estimate changed |
|
||||
| 2026-10-12 | minor | G5: Free Transform options bar H/V skew fields done |
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|
||||
|---|---:|---:|---:|---|
|
||||
| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |
|
||||
| [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 145/256, round trip ≥ 258/256 |
|
||||
| [Tools](#tools) | 28 | 14 | 1 | |
|
||||
| [Tools](#tools) | 29 | 13 | 1 | |
|
||||
| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 157 (target 0) |
|
||||
| [Type](#type) | 4 | 3 | 2 | |
|
||||
| [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) |
|
||||
@@ -147,7 +147,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
|
||||
| TOOL-213-18 | Pattern Stamp tool: sibling of Clone Stamp in the S flyout | done | [#213](https://github.com/storytold/photocraft/issues/213) | Tool::PatternStamp in the S group; paint.patternStamp stamps the Patterns-panel tile with Aligned and Impressionist (an approximation: it jitters each dab's tile phase, not Photoshop's smeared impressionist look); engine tests cover depths, seams, hostile input |
|
||||
| TOOL-214-1 | Select and Mask workspace: view modes, Refine Edge brush, 6 outputs | partial | [#214](https://github.com/storytold/photocraft/issues/214) | select.refineEdge dialog with a live preview in Photoshop's view modes: Onion Skin, Marching Ants, Overlay, On Black, On White, Black & White, On Layers, per-view Opacity, Show Edge (J), Show Original (P), F cycles, X shows the image (select_mask_view.rs, #1754); Refine Edge Brush (R, size, Expand Detection Area / Restore Original Edge, Alt swaps) paints select.refineEdge refineStrokes, estimated by colour-line matting (matting/brush.rs, #2972); outputs Selection, Layer Mask, New Layer, New Layer with Mask, New Document, New Document with Mask (#2998); no workspace layout |
|
||||
| TOOL-214-2 | Marquee: Shift square, Alt from centre, live W x H readout | done | [#214](https://github.com/storytold/photocraft/issues/214) | canvas.rs marquee_corners: Shift square or circle, Alt from the centre, live W x H readout beside the cursor (marquee_readout); marquee_tests.rs |
|
||||
| TOOL-214-3 | Color Range test: Sampled Colors at Fuzziness 0 selects the exact match only | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Fuzziness-0 tests cover midtones/shadows only (selection_cmds.rs:444-447) |
|
||||
| TOOL-214-3 | Color Range test: Sampled Colors at Fuzziness 0 selects the exact match only | done | [#214](https://github.com/storytold/photocraft/issues/214) | color_range_fuzziness_zero_selects_exact_match_only in selection_cmds.rs asserts exact match is selected and 1-level-off pixels are rejected at fuzziness 0; tonal presets covered in color_range_presets |
|
||||
| TOOL-214-4 | Move tool: box-select layers, Auto-Select hover outline, double-click fit, drag to a tab | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Auto-Select hover outline (Preferences › Tools › Show Highlight on Rollover, #2834) and box-select layers from an empty spot (move_box.rs, layer.selectInRect, #2844) done; double-click fit and drag to a tab open |
|
||||
| TOOL-214-5 | Right-click menu during Free Transform (scale, rotate, skew, warp, flip, rotate 90/180) | done | [#214](https://github.com/storytold/photocraft/issues/214) | canvas_tool_menu.rs TRANSFORM_MENU: modes, Content-Aware Scale / Puppet Warp greyed, Rotate 180 / 90 CW / 90 CCW and Flip turn the open box (transform_tool::intercept, #2832) |
|
||||
| TOOL-214-6 | Puppet Warp mesh follows the object outline (constrained triangulation) | done | [#214](https://github.com/storytold/photocraft/issues/214) | algo/puppet.rs build_mesh: traced outline of the opaque region grown by Expansion, triangulated with a Density-spaced lattice (conforming Delaunay); separate shapes get separate meshes (#3105) |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# PhotoCraft vs Adobe Photoshop: target-app parity
|
||||
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (`.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (`.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
The authoritative answer to "how close is PhotoCraft to Photoshop, and how much work is left". The
|
||||
one-page summary is [`ROADMAP.md`](../ROADMAP.md); the ranked work list is [`gaps.md`](gaps.md);
|
||||
@@ -444,7 +444,7 @@ filled bar. This extends UI reachability and does not claim Photoshop-authored s
|
||||
| Smart filters / text / effect shapes in PSDs | Measured on our Photoshop-authored set (https://github.com/storytold/photocraft-corpus, `corpus/photoshop`, 258 files): see the per-group floors in `crates/io/tests/corpus.rs` and `crates/engine/tests/photoshop_oracles.rs`. Smart objects and smart filters now survive PSD save and open (41 corpus files, 206 smart objects, round trip strict; Photoshop opens our exports with live filters); re-rendering Photoshop's smart filters with ours matches 5/30 (was 1/30) | low–medium | Remaining re-render gaps are filter maths (Gaussian/Motion Blur, Unsharp Mask, Emboss, Add Noise RNG) and bicubic placement. |
|
||||
| Core editing (layers, masks, selections, adjustments, filters, transforms) | Broad engine coverage; many interaction bugs fixed after 0.2.0 (adjustment dialogs, Curves, crop, Move/Transform modifiers, gesture origin) | medium | Fixes not yet user-validated. |
|
||||
| UI / UX polish | Shortcut audit 214 → 0 failures; dock, Layers rows and menus reworked; first visual-QA sweep found 14 defects (#147–#157). 2026-10-07: the keyboard-only shortcuts with no menu item (⌥[ ⌥] ⌥, ⌥. layer navigation, ⇧⌥[ ⇧⌥] to extend the selection, 1–0 for opacity and ⇧ for flow or fill, ⇧[ ⇧] hardness, ⌥⌘T to transform a copy and ⌥⇧⌘T to step and repeat), ⌥-click colour sampling with painting tools, double-click a Layers row for Layer Style, File › New from Clipboard, a centred main window and remembered Liquify settings (#352, #417, #350, #368, #419, #418). 2026-10-09: canvas zoom is physical at any display scale — 100% is one document pixel per physical display pixel, and every screen-space overlay, cursor, scrollbar, navigator and fit follows it (#1943) | low–medium | Needs recurring visual QA with realistic documents. |
|
||||
| Tools | 2026-10-10: Pencil, Mixer Brush, Color Replacement, Patch, Content-Aware Move, Vertical Type, Pattern Stamp and Rotate View are toolbar tools. Remaining missing tools include Red Eye, Art History Brush and Frame (Perspective Crop landed 2026-10-10, #1043: `image.perspectiveCrop`) | low–medium | Patch has a live healing preview. Content-Aware Move is partial: Move/Extend, Structure/Color and Sample All Layers exist; Transform On Drop and a live result preview remain missing (`TOOL-213-4` in the scorecard). Magic/Background Eraser added; live gradients in progress (#180). Magnetic Lasso added 2026-10-08 (live-wire edge tracing, Width/Contrast/Frequency, `select.magneticLasso`). Pattern Stamp added 2026-10-08 (S flyout, `paint.patternStamp`, Aligned / Impressionist). Rotate View (2026-10-09) turns the canvas camera around its centre without rewriting pixels; Reset View and Match Rotation copy the angle. Crop rotation (2026-10-09, #1792): dragging outside the crop frame turns it (⇧ 15° steps, angle readout), and ↵ rotates the document and crops in one undo step (`image.crop` `angle`); the frame turns over the image as in Photoshop's Classic Mode, and the options-bar Straighten is still missing. |
|
||||
| Tools | 2026-10-10: Pencil, Mixer Brush, Color Replacement, Patch, Content-Aware Move, Vertical Type, Pattern Stamp and Rotate View are toolbar tools. The only tool still missing is Art History Brush: Frame landed (#2914), Red Eye is a live toolbar tool (`paint.redEye`, TOOL-213-17) and Perspective Crop landed (2026-10-10, #1043, `image.perspectiveCrop`) | low–medium | Patch has a live healing preview. Content-Aware Move is partial: Move/Extend, Structure/Color and Sample All Layers exist; Transform On Drop and a live result preview remain missing (`TOOL-213-4` in the scorecard). Magic/Background Eraser added; live gradients in progress (#180). Magnetic Lasso added 2026-10-08 (live-wire edge tracing, Width/Contrast/Frequency, `select.magneticLasso`). Pattern Stamp added 2026-10-08 (S flyout, `paint.patternStamp`, Aligned / Impressionist). Rotate View (2026-10-09) turns the canvas camera around its centre without rewriting pixels; Reset View and Match Rotation copy the angle. Crop rotation (2026-10-09, #1792): dragging outside the crop frame turns it (⇧ 15° steps, angle readout), and ↵ rotates the document and crops in one undo step (`image.crop` `angle`); the frame turns over the image as in Photoshop's Classic Mode, and the options-bar Straighten is still missing. |
|
||||
| Painting | Brush model and Brush Settings panel near Photoshop; .abr/.grd import; persistent presets; pen pressure/tilt on Windows, web, macOS and X11 | medium | Native Wayland pen input open (#79; a pen opens the window through Xwayland meanwhile); X11 pressure confirmed by a user, macOS not yet verified on tablet hardware. |
|
||||
| Text / typography | Engine works; caret placement and size editing fixed; OpenType features, text-on-path editing, composer parity partial | medium-low | Measure with the Photoshop-authored set. |
|
||||
| Colour management | Colour-managed canvas (document → monitor), embedded CMYK profiles, linear EXR/HDR, 16-bit float canvas | medium-high | Monitor profile follows only at launch. |
|
||||
@@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md).
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the Pen flyout) are live toolbar tools and Frame landed, so Art History Brush is the only tool still missing; percentages unchanged |
|
||||
| 2026-10-12 | minor | Free Transform options bar H/V skew fields; percentages unchanged |
|
||||
| 2026-10-12 | minor | `.atn` import: 112 events mapped (TrueGrit Texture Supply sets play end to end); percentages unchanged |
|
||||
| 2026-10-12 | minor | Photoshop Actions `.atn` load and save (90 events mapped both ways); percentages unchanged |
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
# UI parity: tools, handles, modifiers and feel
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
|
||||
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,
|
||||
@@ -34,13 +34,13 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme
|
||||
| Frame | Frame (frames are groups clipped by a rectangular or elliptical mask) | |
|
||||
| Eyedropper | Eyedropper, Color Sampler, Ruler, Note, Count | |
|
||||
| Retouch | Remove, Spot Healing, Healing, Patch, Content-Aware Move, Red Eye | |
|
||||
| Brush | Brush, Pencil, Mixer Brush | Color Replacement (`paint.colorReplacement` exists) |
|
||||
| Brush | Brush, Pencil, Mixer Brush | |
|
||||
| Stamp | Clone Stamp, Pattern Stamp | |
|
||||
| History | History Brush | Art History Brush |
|
||||
| Eraser | Eraser, Background Eraser, Magic Eraser | |
|
||||
| Fill | Gradient, Paint Bucket | |
|
||||
| Focus, toning | Blur, Sharpen, Smudge, Dodge, Burn, Sponge | |
|
||||
| Pen | Pen, Freeform Pen, Curvature Pen (#1054), Convert Point (#3204; also ⌥ with Pen) | Add Anchor Point, Delete Anchor Point |
|
||||
| Pen | Pen, Freeform Pen, Curvature Pen (#1054), Convert Point (#3204; also ⌥ with Pen), Add Anchor Point, Delete Anchor Point (P cycles them; #4144 auto add/delete with the Pen itself) | |
|
||||
| Type | Horizontal, Vertical, Vertical Type Mask, Horizontal Type Mask | |
|
||||
| Path selection | Path Selection, Direct Selection | |
|
||||
| Shapes | Rectangle, Ellipse, Triangle, Polygon, Line, Custom Shape | (Star is a Polygon option in Photoshop) |
|
||||
@@ -217,6 +217,7 @@ Paragraph; the rest open as in-app floating windows.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the P flyout cycle) are live toolbar tools, so only Art History Brush is missing; no percentage or estimate changed |
|
||||
| 2026-10-13 | minor | Smart object perspective (non-affine) corrected to done: #426 landed four-corner placements with PSD round trip; scorecard FILE-215-6 flipped |
|
||||
| 2026-10-10 | major | First version, from a source audit against Photoshop 2026 27.11.0's shortcuts file and the open issues |
|
||||
| 2026-10-10 | minor | Fixed Crop live resize snapping feedback and outdated-camera rendering, applied ratios immediately to centred inscribed previews, and removed two-point options-bar overflow; added pointer, rendering, dropdown/Enter, Swap/X and scrolling regressions |
|
||||
|
||||
@@ -127,9 +127,9 @@ note = "canvas.rs marquee_corners: Shift square or circle, Alt from the centre,
|
||||
[[item]]
|
||||
id = "TOOL-214-3"
|
||||
target = "Color Range test: Sampled Colors at Fuzziness 0 selects the exact match only"
|
||||
status = "partial"
|
||||
status = "done"
|
||||
issue = 214
|
||||
note = "Fuzziness-0 tests cover midtones/shadows only (selection_cmds.rs:444-447)"
|
||||
note = "color_range_fuzziness_zero_selects_exact_match_only in selection_cmds.rs asserts exact match is selected and 1-level-off pixels are rejected at fuzziness 0; tonal presets covered in color_range_presets"
|
||||
|
||||
[[item]]
|
||||
id = "TOOL-214-4"
|
||||
|
||||
Reference in new issue
Block a user